Core Data: Error, “Can’t Merge Models With Two Different Entities Named ‘foo’ “

For those who come across this question after trying to use core data lightweight migrations: I was having this issue even after following the instructions for creating a new version of my data model. I noticed that there were two “.mom” files in my application bundle, one “.mom” and one “.momd” directory that contained “.mom” … Read more

iPhone CoreData – How to fetch managed objects, and sorting them ignoring case?

Thank you for your reply, but I need to sort the result of a simple “query” ignoring case. Your suggestion applies for searching and comparing. SQL speaking, I need an ORDER BY firstName ASC, and this command must be case insensitive for my usage. I have done some Googling and I ended reading the NSSortDescriptor … Read more

Convert NSArray to Swift Array

I’m currently using obj.types.allObjects as Type[], but that feels like a hack/workaround. Then revise your feelings. What you’re doing is exactly how you do “type-cast / convert the NSArray to Array<Type>[].” An NSArray always arrives into Swift as containing AnyObject (i.e. an Array<AnyObject>, aka AnyObject[]). Casting it down to a specific type, if you know … Read more

NSPersistentCloudKitContainer: How to check if data is synced to CloudKit

To quote “Framework Engineer” from a similar question in the Apple Developer forums: “This is a fallacy”. In a distributed system, you can’t truly know if “sync is complete”, as another device, which could be online or offline at the moment, could have unsynced changes. That said, here are some techniques you can use to … Read more