我遇到了問題。每次我開始我的應用程序崩潰。這是我的代碼。 調試器說:[list count]
崩潰的應用程序。我不知道。 NSLog(@"%@", self.list);
給我按預期的一個項目...爲什麼NSMutableArray Count會崩潰我的應用程序?
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
data = [[NSData alloc] initWithContentsOfFile:filePath];
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
NSMutableArray *array = [unarchiver decodeObjectForKey:@"TOWN"];
[unarchiver finishDecoding];
[unarchiver release];
[data release];
}
self.list = array;
NSLog(@"%@", self.list);
NSLog(@"count %i", [list count]);
被打開了一樣,創建存檔:
Adding *adding = [[Adding alloc] init];
adding.nummer = 1;
adding.stadt = stadt.text;
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[archiver encodeObject:adding forKey:@"TOWN"];
[archiver finishEncoding];
[data writeToFile:[self dataFilePath] atomically:YES];
如果您需要任何futher代碼讓我知道。我將是任何幫助:)
如何宣佈伊娃清單? – 2010-02-08 16:58:32
確實[self.list count]崩潰(是和list.list.name一樣嗎?) – Mark 2010-02-08 17:05:28
是的。一樣的。兩者都崩潰了...... – rdesign 2010-02-08 17:06:23