All Questions
5,408
questions
304
votes
8
answers
90k
views
How to Sync iPhone Core Data with web server, and then push to other devices? [closed]
I have been working on a method to sync core data stored in an iPhone application between multiple devices, such as an iPad or a Mac. There are not many (if any at all) sync frameworks for use with ...
187
votes
26
answers
103k
views
The model used to open the store is incompatible with the one used to create the store
I created a Core Data model in xcode 3.2 and after upgrading in Xcode 4.2, I then added a new entity of the NSManagedObject subclass (refer to the new entity).
First thing, it looks weird because it'...
170
votes
7
answers
78k
views
iphone Core Data Unresolved error while saving
I am getting a strange error message from the core data when trying to save
but the problem that the error is not reproducible ( it appears at different times when doing different tasks)
the error ...
150
votes
11
answers
55k
views
How to filter NSFetchedResultsController (CoreData) with UISearchDisplayController/UISearchBar
I'm trying to implement search code in my CoreData-based iPhone app. I'm not sure how to proceed. The app already has an NSFetchedResultsController with a predicate to retrieve the data for the ...
112
votes
2
answers
50k
views
Coredata Error "data: <fault>"
I try to pull out data from CoreData with the following code
NSFetchRequest *request = [[NSFetchRequest alloc] init];
request.entity = [NSEntityDescription entityForName:@"Cave" ...
110
votes
9
answers
22k
views
Best way to implement Enums with Core Data
What is the best way to bind Core Data entities to enum values so that I am able to assign a type property to the entity? In other words, I have an entity called Item with an itemType property that I ...
101
votes
7
answers
52k
views
How to write a BOOL predicate in Core Data?
I have an attribute of type BOOL and I want to perform a search for all managed objects where this attribute is YES.
For string attributes it is straightforward. I create a predicate like this:
...
94
votes
8
answers
41k
views
JSON and Core Data on the iPhone
I have a core data object graph (consisting of two entities linked by a to-many relationship).
I was curious, as a relatively inexperienced iPhone developer, whether anyone could recommend an ...
89
votes
8
answers
36k
views
How to Deal with Temporary NSManagedObject instances?
I need to create NSManagedObject instances, do some stuff with them and then trash them or store to sqlite db. The problem is, I cannot create instances of NSManagedObject unconnected to ...
88
votes
5
answers
11k
views
iPhone Core Data "Production" Error Handling
I've seen in the example code supplied by Apple references to how you should handle Core Data errors. I.e:
NSError *error = nil;
if (![context save:&error]) {
/*
Replace this implementation with ...
85
votes
7
answers
58k
views
Core Data Primary Key
This may seem stupid, but I still couldn't figure out how to mark a attribute as a primary key in the xcdatamodel file.
My persistent storage is sqlite file.
Can anyone help me?
In that case, how can ...
85
votes
3
answers
28k
views
Example or explanation of Core Data Migration with multiple passes?
My iPhone app needs to migrate its core data store, and some of the databases are quite large. Apple's documentation suggests using "multiple passes" to migrate data to reduce memory use. However, the ...
85
votes
4
answers
18k
views
How to sync CoreData and a REST web service asynchronously and the same time properly propagate any REST errors into the UI
Hey, I'm working on the model layer for our app here.
Some of the requirements are like this:
It should work on iPhone OS 3.0+.
The source of our data is a RESTful Rails application.
We should cache ...
74
votes
11
answers
45k
views
Any way to pre populate core data?
I've been creating a list app and backing it with core data.
I would like to have a default list of say 10 airport's items, so that the user doesn't have to start from scratch.
Is there any way to ...
71
votes
7
answers
40k
views
NSFetchedResultsController with sections created by first letter of a string
Learning Core Data on the iPhone. There seem to be few examples on Core Data populating a table view with sections. The CoreDataBooks example uses sections, but they're generated from full strings ...
67
votes
3
answers
44k
views
Core Data multi thread application
I'm trying to use core data in a multi thread way.
I simply want to show the application with the previously downloaded data while downloading new data in background.
This should let the user access ...
67
votes
6
answers
16k
views
Where to place the "Core Data Stack" in a Cocoa/Cocoa Touch application
In the iPhone Core Data Template, Apple places the Core Data Stack in the App Delegate.
My initial inclination however is to move this code into it's own class whose responsibility is to handle the ...
65
votes
8
answers
54k
views
Creating a unique id for a Core Data program on the iPhone
I am having a bit of trouble figuring out this Core Data stuff. How do I create a new entry with a unique ID? In SQL I would just declare one field as an autoincrement field. I'm not seeing ...
64
votes
9
answers
24k
views
iPhone Core Data "Automatic Lightweight Migration"
I am attempting to update an app that implements a core data store. I am adding an attribute to one of the entities.
I added the following code to my delegate class:
- (...
63
votes
5
answers
42k
views
Fastest way to check if an object exists in Core Data or not?
I want to see if an object is persisted in Core Data or not. For example, I have Friends in Core Data, and I identify them by firstName. I can query core data to see if "George" is known. If the ...
62
votes
4
answers
51k
views
How to create classes after creating Core Data model in Xcode for iPhone
I have created my Model, Entities, Properties and Relationships in Xcode. How are the classes for my Entities created? Do I have to manually create them?
60
votes
6
answers
33k
views
Is there a way to instantiate a NSManagedObject without inserting it?
I have a user interface to insert a Transaction. once the user clicks on a plus he gets the screen and i want to instantiate my Core Data NSManagedObject entity let the user work on it. Then when the ...
60
votes
1
answer
3k
views
More iCloud Core Data synching woes
So, it finally happened. The worst case scenario for any independent iPhone developer occurred. Several users are reporting complete data loss after upgrading my app. iCloud Core Data sync is not ...
59
votes
3
answers
35k
views
NSPredicate that is the equivalent of SQL's LIKE
I'm looking for a way to use NSPredicate to set a LIKE condition to fetch objects. In addition to that, an OR would be useful as well. I'm trying to do something where if a user searches "James" I can ...
58
votes
3
answers
24k
views
How can I track/observe all changes within a subgraph?
I have a NSManagedObjectContext in which I have a number of subclasses of NSManagedObjects such that some are containers for others. What I'd like to do is watch a top-level object to be notified of ...
56
votes
3
answers
35k
views
Use CoreData or SQLite on iPhone? [closed]
Since CoreData has become available for the iPhone in OS 3.0, is it meant to be the answer to data persistence and replace all need for direct SQLite?
What reasons exist to still use SQLite? What are ...
54
votes
9
answers
40k
views
How can I encrypt CoreData contents on an iPhone
I have some information I'd like to store statically encrypted on an iPhone application. I'm new to iPhone development, some I'm not terribly familiar with CoreData and how it integrates with the ...
53
votes
4
answers
45k
views
Core Data primary key ID for a row in the database
Suppose I have a list of books stored in Core Data. I want to search for a book by it's primary key ID.
I know the sqlite file created by Core Data has an ID column in each table, but this doesn't ...
53
votes
4
answers
36k
views
iPhone: Save boolean into Core Data
I have set up one of my core data attributes as a Boolean. Now, I need to set it, but XCode keeps telling me that it may not respond to setUseGPS.
[ride setUseGPS: useGPS.on];
What is the method ...
51
votes
12
answers
68k
views
How to view data stored in Core Data?
I'm creating a Core Data model for my application. I would like to be able to look inside it to see what I have stored in there.
Is there an easier way than searching for the backing store (mine ...
50
votes
5
answers
23k
views
Implementation of "Automatic Lightweight Migration" for Core Data (iPhone)
I would like to make my app able to do an automatic lightweight migration when I add
new attributes to my core data model.
In the guide from Apple this is the only info on the subject I could find:
...
50
votes
7
answers
31k
views
Why should I use Core Data for my iPhone app?
I'm working on my 2nd iPhone app and am curious about Core Data. Time on the project is limited, as is my time overall.
I'm the only dev and I have a feeling that Core Data would be useful but I ...
47
votes
12
answers
25k
views
NSFetchedResultsController crashing on performFetch: when using a cache
I make use of NSFetchedResultsController to display a bunch of objects, which are sectioned using dates. On a fresh install, it all works perfectly and the objects are displayed in the table view. ...
47
votes
4
answers
26k
views
Core Data - Storing Images (iPhone) [closed]
I have an application where I allow the user to add an image for their account.
I wish to know how to store an image (obtained from the camera or photo library) using Core Data, as I may offer a ...
47
votes
6
answers
30k
views
Illegal attempt to establish a relationship 'xyz' between objects in different contexts
I am using Apple's CoreDataBooks sample application as a basis for pulling data into a secondary managed object context in the background, and then merging that data into the primary managed object ...
46
votes
4
answers
16k
views
What are the limitations of NSUserDefaults?
Storing data permanently in an iPhone is usually done using Core Data or sqlite3. Most people prefer to user NSUserDefaults as a storage for application preferences, rather than using it as a normal ...
45
votes
4
answers
20k
views
NSManagedObjectContext performBlockAndWait: doesn't execute on background thread?
I have an NSManagedObjectContext declared like so:
- (NSManagedObjectContext *) backgroundMOC {
if (backgroundMOC != nil) {
return backgroundMOC;
}
backgroundMOC = [[...
43
votes
9
answers
38k
views
Core Data NSPredicate checking for BOOL value
I am currently having an issue pulling all data from db whereby i.e 1 parameter is TRUE.
I am using NSPredicate and below is a sample code
NSManagedObjectContext *context = managedObjectContext_;
...
43
votes
8
answers
17k
views
core data in a static library for the iPhone
I've built a static library that makes heavy use of the Core Data framework. I can successfully use the library in my external project, but ONLY if I include the .xcdatamodel file in the main project. ...
43
votes
3
answers
16k
views
CoreData: error: NULL _cd_rawData but the object is not being turned into a fault
I occasionally get this error when saving to core data. I cannot manage to recreate it.
Does anyone have any experience with this error;
CoreData: error: NULL _cd_rawData but the object is not being ...
42
votes
4
answers
34k
views
Core Data, NSPredicate and to-many key
I have a Core Data model in which a Task entity includes an optional to-many relationship excludedOccurrences. One of the properties of excludedOccurrences is start, which is an NSDate object. The ...
42
votes
6
answers
15k
views
Core Data and threads / Grand Central Dispatch
I'm a beginner with Grand Central Dispatch (GCD) and Core Data, and I need your help to use Core Data with CGD, so that the UI is not locked while I add 40.000 records to Core Data.
I know that CD is ...
42
votes
7
answers
18k
views
Cryptic error from Core Data: NSInvalidArgumentException, reason: referenceData64 only defined for abstract class
I'm doing an iPhone app that reads data from XML file, turn them into Core Data Managed Objects and save them.
The application is working fine, mostly, on smaller data set/XML that contains ~150 ...
42
votes
1
answer
5k
views
Search Core Data for all objects with an empty "to-many" relationship
In an almost identical situation to Core Data - Fetch all objects NOT in a relationship, only I'm looking for all records of one type that are not in any to-many relationship with another type.
So let'...
41
votes
4
answers
19k
views
Core Data NSFetchedResultsController - Total number of records returned
I'm using an NSFetchedResultsController in an iPhone app, and am wondering if there is some easy way of getting the total number of rows returned in all sections.
Instead of getting the [[...
41
votes
7
answers
25k
views
Core Data - How to fetch an entity with max value property
I have a entity Person with a property personId (personId is unique)
How can I fetch the Person with the max personId?
(I want to fetch the person itself not the value of the property)