-2

I have a problem with my Xcode app, When I push a button, my app crashes.

Here is my button's action, I also declared variables, strings, etc... but it isn't in this code:

{
    NSLog(@" - Writing Data.plist Labels");
    NSString *error;
    NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];

    NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Data.plist"];
    NSDictionary *plistDict = [NSDictionary dictionaryWithObjects:
                               [NSArray arrayWithObjects: compteur01, compteur02, compteur03, compteur04, compteur05, compteur06, nil]
                                                          forKeys:[NSArray arrayWithObjects: @"name1", @"name2", @"name3", @"name4", @"name5", @"name6", nil]];
    NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict
                                                                   format:NSPropertyListXMLFormat_v1_0
                                                         errorDescription:&error];
    if(plistData) {
        [plistData writeToFile:plistPath atomically:YES];
    }
    else {
        NSLog(@"Error writeToFile:plistData:labels");
        [error release];
    }
}
4

1 回答 1

0

Aparently compteur01 is nil. Most likely the other compteur0x are nil too. But for this message at least the first one is nil.

Make sure that none of the objects added to the dictionary are nil. Use NSNULL instead if you need them to represent a nil/null value.

于 2013-03-30T13:30:42.223 回答