Skip to content

Commit

Permalink
Use the new ObjC Interop functions in RealmSwift 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Fish committed Dec 15, 2016
1 parent 3b5490d commit a571344
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 56 deletions.
2 changes: 2 additions & 0 deletions RBQFetchedResultsController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.Roobiq.SwiftFetchedResultsController;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -619,6 +620,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ open class FetchRequest<T: Object> {

self.realmConfiguration = realm.configuration

let rlmConfiguration: RLMRealmConfiguration = Realm.toRLMConfiguration(realm.configuration)
let rlmConfiguration: RLMRealmConfiguration = ObjectiveCSupport.convert(object: realm.configuration)

let rlmRealm = try! RLMRealm(configuration: rlmConfiguration)

Expand Down
55 changes: 0 additions & 55 deletions RBQFetchedResultsController/Source/Swift/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,58 +47,3 @@ extension Object {
return false
}
}

/**
Category on Realm that provides convenience methods similar to Realm class methods but include notifying RBQRealmNotificationManager
*/
extension Realm {

// MARK: Helper Functions To Bridge Objective-C

/**
Convenience method to convert Configuration into RLMRealmConfiguration
:nodoc:
*/
internal class func toRLMConfiguration(_ configuration: Configuration) -> RLMRealmConfiguration {
let rlmConfiguration = RLMRealmConfiguration()

if let syncConfig = configuration.syncConfiguration {
rlmConfiguration.syncConfiguration = RLMSyncConfiguration(user: syncConfig.user, realmURL: syncConfig.realmURL)
}

// Hack to get around issue with cache objects appearing in Realm
// when building RBQFRC not as a framework
let mirror = Mirror(reflecting: configuration)
for child in mirror.children {
if let customSchema = child.value as? RLMSchema, "customSchema" == child.label {
// Filter out cache objects
let schemaSubset = customSchema.objectSchema.filter { (objectSchema) -> Bool in
let cacheObjectNames = ["RBQControllerCacheObject",
"RBQObjectCacheObject",
"RBQSectionCacheObject"]

if cacheObjectNames.contains(objectSchema.objectName) {
return false
}

return true
}

rlmConfiguration.objectClasses = schemaSubset.map { $0.objectClass }
}
}

if (configuration.fileURL != nil) {
rlmConfiguration.fileURL = configuration.fileURL
}

if (configuration.inMemoryIdentifier != nil) {
rlmConfiguration.inMemoryIdentifier = configuration.inMemoryIdentifier
}
rlmConfiguration.encryptionKey = configuration.encryptionKey
rlmConfiguration.readOnly = configuration.readOnly
rlmConfiguration.schemaVersion = configuration.schemaVersion
return rlmConfiguration
}
}

0 comments on commit a571344

Please sign in to comment.