Reputation: 10245
I have set up coredata in my application which I am reading a NSData object into.. I have check to make sure all is fine and that the values are there, which they are and now I would like to pull that nsdata out and pass it to a method in my class.. But I am not sure how to read something like this from coredata..
The example I have seen of reading values from coredata is from the template code XCode generates.. but this is for an objectAtIndexPath:indexPath value... as shown below..
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
NSManagedObject *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [[object valueForKey:@"timeStamp"] description];
}
So I am hoping there is a way just to pull all of the NSData out of the attribute.. because thats all I have is just a blob of data that I parse myself.
any help would be greatly appreciated.
Update:
Okay so this is now how I am reading the data from my coredata store thanks to the great tutorial listed below.
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Manz" inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:nil];
for (NSManagedObject *info in fetchedObjects) {
[self startTheParsingProcess:[info valueForKey:@"masters"]]; //Send to a method if you like
// NSLog(@"content od coredata %@", [info valueForKey:@"masters"]); // Or log it to see whats in your coredata
}
Upvotes: 1
Views: 1294