Reputation: 16128
Im using coredata to check the content of an entity, but still remembering how to go about to do it,
PFIWIAppDelegate* delegate = (PFIWIAppDelegate*)[[UIApplication sharedApplication] delegate];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"productPoints" inManagedObjectContext:[delegate managedObjectContext]];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entity];
NSLog(@" la resposta por deux:: %@", request);
NSError *error = nil;
NSArray *results = [[delegate managedObjectContext] executeFetchRequest:request error:&error];
NSLog(@"tu fetch master db ::%@",results);
so im sure there are properties in my entity "productPoints" [checked in sqlite Manager)
how to see the data?
in my logs I see
la resposta por deux:: <NSFetchRequest: 0x6cd1780> (entity: productPoints; predicate: ((null)); sortDescriptors: ((null)); type: NSManagedObjectResultType; )
2011-12-14 14:50:44.266 PFIWIN0196[7524:fb03] tu fetch master db ::(
"<productPoints: 0x6cd38c0> (entity: productPoints; id: 0x6cd2ce0 <x-coredata://888E340F-6CBF-4EED-B9D9-9C3FB06244F3/productPoints/p6> ; data: <fault>)",
"<productPoints: 0x6cd3b70> (entity: productPoints; id: 0x6cd2cf0 <x-coredata://888E340F-6CBF-4EED-B9D9-9C3FB06244F3/productPoints/p7> ; data: <fault>)"
so i guess im seeing the 2 objects of my entity, but how to see the properties,
thanks!
Upvotes: 0
Views: 502
Reputation: 54796
Your objects are in the results
array, as you surmise. To see the properties all you have to do is access them, using something along the lines of:
productPoints* firstProduct = [results objectAtIndex:0];
NSLog("Some property value: %@", firstProduct.someProperty);
Also note that the standard Core Data API's are absolutely ridiculous for a framework that is supposed to simplify the task of storing and retrieving data. I strongly suggest you try using the NSManagedObjectContext+EasyFetch
category discussed here and in github here.
Then your code can be rewritten as:
PFIWIAppDelegate* delegate = (PFIWIAppDelegate*)[[UIApplication sharedApplication] delegate];
NSArray* results = [[delegate managedObjectContext] fetchObjectsForEntityName: @"productPoints"];
NSLog(@"tu fetch master db ::%@",results);
Upvotes: 3