Originally created by @wbuchner on GitHub (Mar 29, 2017).
Im updating from Swift 2 -> 3.1.0 and run across an issue I need some help with.
My class is below. It works beautifully in Swift 2.0 and I haven't had any issues. I am experiencing an issue with some warnings, and the Xcode telling me that I am not fully complying with the protocol. I can't see anything missing.
Can you please see what I cannot? I would appreciate it.
This is the warning I am getting
publicclassContact:SEManagedObject,ImportableUniqueObject{publictypealiasImportSource=[String:AnyObject]publictypealiasUniqueIDType=NSObject/**
Description
- parameter data: the dictionary with the data to save
- returns
*/classfuncstoreContact(data:[NSDictionary],success:@escaping(SaveResult)->Void,failure:@escaping(SaveResult)->Void){// swiftlint:disable:next identifier_nameCoreStore.beginAsynchronous{(AsynchronousDataTransaction)inletresult=try!AsynchronousDataTransaction.importUniqueObjects(Into(Contact.self),sourceArray:(dataas?[[String:AnyObject]])!)}}publicfuncupdate(fromsource:Contact.ImportSource,intransaction:BaseDataTransaction)throws{}// swiftlint:disable:next function_body_lengthpublicstaticfuncshouldUpdate(fromsource:Contact.ImportSource,intransaction:BaseDataTransaction)->Bool{// all insert code herereturntrue}publicstaticfuncshouldInsert(fromsource:Contact.ImportSource,intransaction:BaseDataTransaction)->Bool{returntrue}publicvaruniqueIDValue:NSObject{get{returnself.identification!asNSObject}set{self.identification=(newValueas?String)!}}publicfuncdidInsert(fromsource:Contact.ImportSource,intransaction:BaseDataTransaction)throws{}publicstaticvaruniqueIDKeyPath:String{return"identification"}publicstaticfuncuniqueID(fromsource:Contact.ImportSource,intransaction:BaseDataTransaction)throws->Contact.UniqueIDType?{letcontact=source["contact"]returncontact!["Id"]as?NSString}}
Originally created by @wbuchner on GitHub (Mar 29, 2017).
Im updating from Swift 2 -> 3.1.0 and run across an issue I need some help with.
My class is below. It works beautifully in Swift 2.0 and I haven't had any issues. I am experiencing an issue with some warnings, and the Xcode telling me that I am not fully complying with the protocol. I can't see anything missing.
Can you please see what I cannot? I would appreciate it.
This is the warning I am getting

```swift
public class Contact: SEManagedObject, ImportableUniqueObject {
public typealias ImportSource = [String:AnyObject]
public typealias UniqueIDType = NSObject
/**
Description
- parameter data: the dictionary with the data to save
- returns
*/
class func storeContact(
data: [NSDictionary],
success: @escaping (SaveResult) -> Void,
failure: @escaping (SaveResult) -> Void) {
// swiftlint:disable:next identifier_name
CoreStore.beginAsynchronous { (AsynchronousDataTransaction) in
let result = try! AsynchronousDataTransaction.importUniqueObjects(
Into(Contact.self), sourceArray: (data as? [[String:AnyObject]])!
)
}
}
public func update(from source: Contact.ImportSource, in transaction: BaseDataTransaction) throws {
}
// swiftlint:disable:next function_body_length
public static func shouldUpdate(from source: Contact.ImportSource,
in transaction: BaseDataTransaction) -> Bool {
// all insert code here
return true
}
public static func shouldInsert(from source: Contact.ImportSource,
in transaction: BaseDataTransaction) -> Bool {
return true
}
public var uniqueIDValue: NSObject {
get { return self.identification! as NSObject }
set {
self.identification = (newValue as? String)!
}
}
public func didInsert(from source: Contact.ImportSource, in transaction: BaseDataTransaction) throws {
}
public static var uniqueIDKeyPath: String {
return "identification"
}
public static func uniqueID(from source: Contact.ImportSource,
in transaction: BaseDataTransaction) throws -> Contact.UniqueIDType? {
let contact = source["contact"]
return contact!["Id"] as? NSString
}
}
```
adam
added the question label 2025-12-29 18:23:24 +01:00
@wbuchner Hi, starting CoreStore 3.0.3 the ImportSource does not need to be NSObject.
You can use typealias UniqueIDType = String or NSString directly.
Also, var uniqueIDValue now has a default protocol implementation (you can remove it completely from your code) as long as you specify the var uniqueIDKeyPath correctly.
Please check ImportableUniqueObject.swift for the actual changes and ImportableAttributeType.swift for a list of supported UniqueIDType types.
@JohnEstropia commented on GitHub (Mar 29, 2017):
@wbuchner Hi, starting CoreStore 3.0.3 the `ImportSource` does not need to be `NSObject`.
You can use `typealias UniqueIDType = String` or `NSString` directly.
Also, `var uniqueIDValue` now has a default protocol implementation (you can remove it completely from your code) as long as you specify the `var uniqueIDKeyPath` correctly.
Please check ImportableUniqueObject.swift for the actual changes and ImportableAttributeType.swift for a list of supported `UniqueIDType` types.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @wbuchner on GitHub (Mar 29, 2017).
Im updating from Swift 2 -> 3.1.0 and run across an issue I need some help with.
My class is below. It works beautifully in Swift 2.0 and I haven't had any issues. I am experiencing an issue with some warnings, and the Xcode telling me that I am not fully complying with the protocol. I can't see anything missing.
Can you please see what I cannot? I would appreciate it.
This is the warning I am getting

@JohnEstropia commented on GitHub (Mar 29, 2017):
@wbuchner Hi, starting CoreStore 3.0.3 the
ImportSourcedoes not need to beNSObject.You can use
typealias UniqueIDType = StringorNSStringdirectly.Also,
var uniqueIDValuenow has a default protocol implementation (you can remove it completely from your code) as long as you specify thevar uniqueIDKeyPathcorrectly.Please check ImportableUniqueObject.swift for the actual changes and ImportableAttributeType.swift for a list of supported
UniqueIDTypetypes.@wbuchner commented on GitHub (Mar 29, 2017):
Thank you John!