Closed WelkinDev closed 3 years ago
Or use ObjectId.generate().stringValue, will it cause other problem?
You can useUUID().uuidString
instead for generating random ids if ObjectID.generate is causing any issues. Other than that, how are you setting the primary key? AFAIK only int and string primary values are currently supported.
UUID().uuidString
method I used before, but some strange problems can occur on MacOS. ObjectId.generate()
is fine.
Now the code looks like this, Everything seems normal now.
@objc dynamic var identifier = ObjectId.generate().stringValue
override class func primaryKey() -> String? { return "identifier" }
Behavior: As I use ObjectId as primary key, app will crash when set CreamAsset property
Suggestion: Try to pass ObjectId as String or Int when use ObjectId as primary key, and exchange to ObjectId after sync complete