I need to create a copy/save/duplicate of listID
attribute of NSManagedObject list
. The scenario is first delete list from local store and then i send request to server for deleting list
objects using their id but when i delete objects from local store there i cannot then access object ids. Following is the code
List *list = (List*)[self.fetchedResultsController objectAtIndexPath:indexPath];
NSString *listID = [list.listID stringValue];
[listsToDelete addObject:listID];
[context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
i tried to store object id string value in an array for later use but no avail because if at later i access listToDelete
it is nil. Why do i need to do to achieve this?
Based on the limited code you have shown, a few things come to mind:
1) Did you initialize your listsToDelete? I imagine that is an NSMutableArray
type. You need to initialize it properly.
IE. NSMutableArray* listsToDelete = [[NSMutableArray alloc] init];
2) Have you tried logging the value of list.listID
prior to adding it into your array? Maybe the value was nil
to begin with?