On loading the view I get
ProjectEditColourListView: @self, @identity, _viewContext, _editMode, _colourList, @64, @88, _searchText, _isShowingFilterView, _appSetting, _filters changed.
ProjectEditColourListView: @self changed.
ProjectEditColourListView: @88 changed.
Then after selecting a cell
ProjectEditColourListView: @88 changed.
ProjectEditColourListView: @self changed.
ProjectEditColourListView: @88 changed.
ProjectEditColourListView: @self changed.
ProjectEditColourListView: @self changed.
Post
Replies
Boosts
Views
Activity
After a bit of digging it appears the issue isn't related to to conversion itself. It's occurring when writing the data to core data.
I can resolve it by refreshing the context after each project save, but not sure if its the best way of doing it.
My previous view has the navigation stack in it
Seems like I can alter the onAppear method to do what I want
.onAppear() {
items.nsPredicate = NSPredicate(format: "series = %@ AND amount = 0", series)
if(!searchText.isEmpty) {
items.nsPredicate = NSPredicate(format: "series = %@ AND amount = 0 AND name CONTAINS[cd] %@", series, searchText)
}
}
How would I get the records when core data deals with it behind the scenes?
OK, so I can see that the notification is being fired and the value is being changed but the notification appears to be fired after the initial import is done.
From the notification
NSLog("First Run: \(String(describing: notification.userInfo))")
First Run: Optional([AnyHashable("NSUbiquitousKeyValueStoreChangedKeysKey"): <__NSArrayM 0x60000391c450>( firstRun, timeGrouping, imageThumbSize, dbVersion ) , AnyHashable("NSUbiquitousKeyValueStoreChangeReasonKey"): 1]) Launching the application
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
		appData.moc = persistentContainer.viewContext
		NotificationCenter.default.addObserver(self, selector: #selector(onUbiquitousKeyValueStoreDidChangeExternally(notification:)), name: NSUbiquitousKeyValueStore.didChangeExternallyNotification, object: NSUbiquitousKeyValueStore.default)
		performUpdates()
		return true
}
and the performUpdates function
		func performUpdates() {
let firstRunPref: Bool = prefs.bool(forKey: "firstRun")
let firstRun: Bool = keyValStore.bool(forKey: "firstRun")
if(!firstRun) {
// Check for old prefs, if existing, there is already data in the db
if(!firstRunPref) {
// No previous data
keyValStore.set(true, forKey: "firstRun")
NSLog("First Run: Yes inital keyval, no prefs, initial import")
} else {
// Previous data exists
keyValStore.set(true, forKey: "firstRun")
NSLog("First Run: Yes inital keyval, previous prefs, convert")
}
} else {
updates(useKeyVal: true)
NSLog("First Run: No, update")
}
}
The sizes vary, they come from either the camera or the photo library. Formats may vary as well