Post

Replies

Boosts

Views

Activity

NSBatchInsertRequest problem with decoding a simple Date
Hi,I have backup functionality which takes the NSManaged Object and save them as JSON File.The JSON looks like this :[ { "id": "58454F9D-08BC-4302-A5FC-11545EFB8C42", "created": 608479894.33327103, "name": "Freezer", "modified": 608479894.33327198 }, { "id": "3AB234DF-E16D-43BE-AA57-CA14E729EEA8", "created": 608479894.33316803, "name": "Fridge", "modified": 608479894.33318496 }, { "id": "6FA1E8D0-8629-413B-9C71-0377260ECFFF", "created": 608479894.33331501, "name": "Pantry", "modified": 608479894.33331501 } ]And the corresponding NSManagedObject class looks as Below :@objc(Storage) class Storage: NSManagedObject, Encodable { // MARK: - Properties @NSManaged public var id: String @NSManaged public var name: String @NSManaged public var created: Date @NSManaged public var modified: Date // MARK: - Encodable public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: .id) try container.encode(created, forKey: .created) try container.encode(modified, forKey: .modified) try container.encodeIfPresent(name, forKey: .name) } }As you can see it is a pretty simple NSManagedObject class, and both the JSON keys and the class attributes matches.The problem is that by using the NSBatchInsertRequest to import the JSON file back to the database this fails in the Created Date field parsing, whith the following error :Error Domain=NSCocoaErrorDomain Code=1550 "created is not valid." UserInfo={NSValidationErrorObject=<NSSQLiteConnection: 0x7f809c607a90>, NSLocalizedDescription=created is not valid., key=created, value=608485537.09696996, NSValidationErrorKey=created, NSValidationErrorValue=608485537.09696996}Is there something I have missed, does NSBatchInsertRequest use it own Date parser different that the one defined by default On Swift JSON ?Looking forward for your help.
5
0
1.5k
Jun ’20
SetFocusFilterIntent perform macCatalyst not being called
I added recently FocusFocus support to an app built with UiKit for iOS iPadOS and uses macCatalyst for macOS, the perform method on SetFocusFilterIntent is called without any issue when I test the app under iOS or iPadOS when the Focus changes, but under macOS nothing happens (perform method in SetFocusFilterIntent is not called when focus changes). Is there a missing configuration that I need explicitly to add for this to work also under macOS ? Is this a known issue and will be addressed on a newer update of macOS Ventura ?
0
0
670
Oct ’22
SwiftUI Form under macOS looks like iOS
I have been migrating from old UiKit to use SwiftUI form, I use of course .formStyle(.grouped). Only issue that I'm having is that under macOS the forms looks a bit like iOS and I didn't find any way to make it look like it was shown on the WWDC with a gray transparent background. Is this not supported out of the box and I need to write a custom code to achieve that look ? or am I missing a configuration ? This is how my current form looks like on macOS : I Would wish if I could make it look like: I do use the same formStyle and Form element but the look is different the background is while and not gray transparent.
1
0
1.8k
Mar ’23