Thank you for your fast reply :-)
I've found in my code that this error occurs when I retrieve data from a .plist file. (I have a list of element that a user can manage by adding, moving, editing data - like a list of book - and this list is saved in the Documents folder of the App). The code I use to retrieve data is the following:
Code:
+ (NSString *)pathForDocumentWithName:(NSString *)documentName
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *path = [paths objectAtIndex:0];
return [path stringByAppendingPathComponent:documentName];
}
- (NSMutableArray *)displayedObjects
{
if (_displayedObjects == nil)
{
NSString *path = [[self class] pathForDocumentWithName:@"Books.plist"];
NSArray *booksDicts = [NSMutableArray arrayWithContentsOfFile:[path stringByStandardizingPath]];
if (booksDicts == nil)
{
NSLog(@"Unable to read plist file at path: %@", path);
path = [[NSBundle mainBundle] pathForResource:@"Books"
ofType:@"plist"];
booksDicts = [NSMutableArray arrayWithContentsOfFile:path];
}
_displayedObjects = [[NSMutableArray alloc]
initWithCapacity:[booksDicts count]];
for (NSDictionary *currDict in booksDicts)
{
Book *books = [[Book alloc] initWithDictionary:currDict];
[_displayedObjects addObject:books];
}
}
return _displayedObjects;
}
where "Book" is the class that manage the list. If there is no file (like the first use) I don't have problem with the calling of the class "Book" and the dictionary: objectForKey . The error occurs in the bold row, and I don't know how figure it out.