I want to get a single object from my Core Data datastore, here is the code I have been using but it returns an array of objects, there must be a simpler and better way:
NSFetchRequest *request= [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Manufacturer" inManagedObjectContext:managedO...
I have a one to many entity relationship between two entities:
EntityP (Parent) <-->> EntityC (Child)
Attributes and Relationships:
EntityP.title
EntityP.dateTimeStamp
EntityP.PtoC (relationship)
EntityC.title
EntityC.dateTimeStamp
EntityC.CtoP (relationship) // Can be used to get "one" EntityP record
I use fetch results controlle...
I'm developing for iPhone iOS 4.0 and I have a list of birthday objects (date + name) stored using Core Data. I want to use the NSFetchedResultsController to retrieve this list sorted by the next birthdate date of each birthday object. For that I need to define my own logic for the sort descriptor.
I tried using:
[NSSortDescriptor sort...
I have a typedef enum I use to represent a state of a job in a queueing system and it is defined as
typedef enum {
kTWjobStateRunning,
kTWjobStateQueued,
kTWjobStateError
}TWjobState;
Everything is fine, but now I would like to store it as an attribute in CoreData. My first idea is that an enum is basically an integer, so would wrapp...
I need to identify items of interest nearby to a particular latitude/longitude. I have two sets of objects stored in Core Data:
PostalArea
- latitude
- longitude
- postcode
Store
- name
- latitude
- longitude
I need to be able to retrieve a record from the PostalArea table, and then find stores which are closeby.
Most of the examp...
I have some basic questions about core data (which I am new to) and I would like some points of view on current standards and implementations.
Basically I have an app on the iPhone (supporting iOS 3.0 and above) which gets a lot of data from web calls over HTTP, Im looking at moving the results into local storage for fast retrieval for ...
I am working on a project where the app parses data from an XML file, saves it to a persistent store and populates a table view. Every time the app opens, if there is internet connection available, the persistent store gets recycled and the XML is parsed again as it gets updated quite frequently. If no internet connection is available I'...
Hi,
I try to delete some managedobjects by calling in a for loop
[managedObject delete];
and at of the loop, I call
[managedObjectContext save:nil];
At the above line, the app crashes and goes nowhere from there. Any ideas?
Thanks
...
Is there a way to cache NSFetchRequest results, but without using an NSFetchedResultsController? I know how to set the cache name for the results controller, but in a number of instances I just pull data from my core data store and want to cache it -- but have no need for a results controller. Any ideas on how to do this? I can't find an...
I am importing a bunch of data from a web service on a background thread and I randomly run into bad access problems, I believe mostly from assigning relationships.
I am wondering how long the new entities I create and save hang around?
...
In my app I create and use a normal persistent store:
- (NSPersistentStoreCoordinator *) persistentStoreCoordinator {
// D_IN;
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self mana...
Hello,
I'm working on an iPhone application that downloads data from a web server and I sometimes, but not always, want to cache the results of these downloads. The entity I'm dealing with is an Event. Events appear in the UI in the following ways:
as the result of a location-based search
as the result of a keyword-based search
a list...
I'm a novice iphone developer, and just completed my first iphone app.
After provisioning my iphone for development, I noticed that the app used way too much memory, and that several memory leaks that were issuing from the app accessing the sqlite database in the app caused the app to crash often. After running instruments, I have decid...
My test code:
NSManagedObjectContext *context;
.....
NSAutoreleasePool *pool = [NSAutoreleasePool new];
User *u = (User *)[NSEntityDescription insertNewObjectForEntityForName:@"User" inManagedObjectContext:context];
NSLog(@"after create:%d", [u retainCount]);
[context deleteObject:u];
NSLog(@"after delete:%d", [u retainCount]);
[context...
In data model I have transient property uppercaseFirstLetterOfName which will return first letter of persistent property. I specify this property in
NSSortDescriptor* sortByWordDescriptor = [[NSSortDescriptor alloc]
initWithKey:@"subject" ascending:YES];
NSArray* sortArray = [[NSArray alloc]
ini...
I've read a number of posts here about NSManagedObjectContext and multi-threaded applications. I've also gone over the CoreDataBooks example to understand how separate threads require their own NSManagedObjectContext, and how a save operation gets merged with the main NSManagedObjectContext. I found the example to be good, but also too...
Welcome
i use Core Data to store datas. i need such a method which returns only the last 7 elements of entity. my question is how should i modify this code ( it fetchs all of elements, but i need only last 7)
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Trip" inManagedObjectContext:managedObjectContext];
NSFet...
In my Core Data model I have a property which is a NSDate, the user can change it and it is optional.
I would like to set this property's default value as today, I saw no way to do this in the Core Data Model so I subclassed NSManangedObject and added this code to the implementation file.
- (NSDate *)date {
return [NSDate date];
}
...
hi
i use CoreData to store datas, and i have got some entities.
how can i do some custom statements through CoreData ?
so exactly i mean i don't want to fetch all of records in datatable but for example "every elements where keyValue=something" and no more. or for example last 3 elements. etc, etc.
so what way can i do custom statemen...
I am trying to see if cache files are successfully created but can't find their location on the disk (neither on simulator nor iPhone device)
Any ideas?
...