How to create a single shared framework between iOS and OS X

If you wish to create a single dynamic framework binary, here are the steps you can follow (as outlined in http://colemancda.github.io/2015/02/11/universal-ios-osx-framework): 1. Change the project’s valid architectures and supported platforms. This should change your framework’s and test unit’s valid architectures and supported platforms as well. If not, then manually change them to inherit from the … Read more

CoreData: error: NULL _cd_rawData but the object is not being turned into a fault

Reason: This happens when the object’s context does not belong to the current thread. One of many ways that mistake can manifest itself. Debug: When the crash occurs do the following: Check the thread in which the crash occured (Xcode > Debug Navigator) On the console print, the concurrency type of the NSManagedObjectContext If the … Read more

core data in a static library for the iPhone

Sascha’s answer got me on the right track. Merging a compiled .mom file from a static library into the .mom file from a host project was relatively simple. Here’s a trivial example: Create a new XCode Static Library project called MyStaticLibrary Create an .xcdatamodel file in MyStaticLibrary called MyStaticLibraryModels.xcdatamodel, add some Entitys, then generate the … Read more

CoreData get distinct values of Attribute

You should use the backing store to help you get distinct records. If you want to get an array with just John, Betty, Edward here’s how you do it: NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@”MyEntity”]; NSEntityDescription *entity = [NSEntityDescription entityForName:@”MyEntity” inManagedObjectContext:self.managedObjectContext]; // Required! Unless you set the resultType to NSDictionaryResultType, distinct can’t work. // All objects … Read more

NSManagedObjectContext performBlockAndWait: doesn’t execute on background thread?

Tossing in another answer, to try an explain why performBlockAndWait will always run in the calling thread. performBlock is completely asynchronous. It will always enqueue the block onto the queue of the receiving MOC, and then return immediately. Thus, [moc performBlock:^{ // Foo }]; [moc performBlock:^{ // Bar }]; will place two blocks on the … Read more

How do I sort a swift array containing instances of NSManagedObject subclass by an attribute value (date)

This is partly an issue with the Swift compiler not giving you a helpful error. The real issue is that NSDate can’t be compared with < directly. Instead, you can use NSDate‘s compare method, like so: days.sort({ $0.date.compare($1.date) == NSComparisonResult.OrderedAscending }) Alternatively, you could extend NSDate to implement the Comparable protocol so that it can … Read more

Lightweight migration of a NSPersistentDocument

The compiled .momd resources can be loaded after an “existingPartner” fetch request is changed from: name == $name to: name == $NAME It’s counterintuitive that a part of the object model that does not affect the persistence of data breaks versioning and lightweight migration. It’s clear from the documentation that this should not be the … Read more

What are the limitations of NSUserDefaults?

Sqlite3 is more useful for keeping large database and to access to the database elements. You can sort the items of Sqlite3 database, you can search very fast for item in Sqlite3 dtabase. Sqlite3 database has many privileges that NSUserDefaults didn’t have ! NSUserDefaults vs Sqlite3 NSUserDefaults is for user preferences, usually basic objects like … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)