NSPredicate: filtering objects by day of NSDate property

Given a NSDate * startDate and endDate and a NSManagedObjectContext * moc: NSPredicate *predicate = [NSPredicate predicateWithFormat:@”(date >= %@) AND (date <= %@)”, startDate, endDate]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:[NSEntityDescription entityForName:@”EntityName” inManagedObjectContext:moc]]; [request setPredicate:predicate]; NSError *error = nil; NSArray *results = [moc executeFetchRequest:request error:&error];

How to get Core Data object from specific Object ID?

You want: -(NSManagedObject *)existingObjectWithID:(NSManagedObjectID *)objectID error:(NSError **)error Fetches the object from the store that has that ID, or nil if it doesn’t exist. (Be aware: there are two methods on NSManagedObjectContext with similar-seeming names that tripped me up. To help keep them straight, here’s what the other two do: -(NSManagedObject *)objectWithID:(NSManagedObjectID *)objectID …will create a … Read more

How to save Array to CoreData?

Ok, I made some research and testing. Using Transformable type, solution is simple: 1. What do I declare inside my NSManagedObject class? @NSManaged var values: [NSNumber] //[Double] also works 2. What do I declare inside my .xcdatamodel? Transformable data type. 3. How do I save this in my Entity? statistics!.values = [23, 45, 567.8, 123, … Read more

Xcode 6 iPhone Simulator Application Support location

The simulator directory has been moved with Xcode 6 beta to… ~/Library/Developer/CoreSimulator Browsing the directory to your app’s Documents folder is a bit more arduous, e.g., ~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite

Unable to find specific subclass of NSManagedObject

Update for Xcode 7 (final): Prepending the module name to the class (as in Xcode 6 and early beta releases of Xcode 7) is no longer necessary. The Apple documentation Implementing Core Data Managed Object Subclasses has been updated accordingly. The Data Model inspector has now two fields “Class” and “Module” for an entity: When … Read more

Adding Core Data to existing iPhone project

All the CoreData header files are imported in App_Prefix.pch, so the CoreData classes will be available throughout your Project, so you don’t have to manually import the header in the files you need them. So open up Xcode and look for some file like App_Prefix.pch, by default it’s in the Other Sources group. After the … Read more

How to filter NSFetchedResultsController (CoreData) with UISearchDisplayController/UISearchBar

I actually just implemented this on one of my projects (your question and the other wrong answer hinted at what to do). I tried Sergio’s answer but had exception issues when actually running on a device. Yes you create two fetch results controllers: one for the normal display and another one for the UISearchBar’s table … Read more

Does every Core Data Relationship have to have an Inverse?

Apple documentation has an great example that suggest a situation where you might have problems by not having an inverse relationship. Let’s map it into this case. Assume you modeled it as follows: Note you have a to-one relationship called “type“, from SocialApp to SocialAppType. The relationship is non-optional and has a “deny” delete rule. … Read more

iphone Core Data Unresolved error while saving

It means there’s a mandatory property has been assigned nil. Either in your *.xcodatamodel check the “optional” box or when you are saving to the managedObjectContext make sure that your properties are filled in. If you’re getting further errors after changing your code to suit the two requirements try cleaning your build and delete the … Read more

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