今天一直發生底下的exception:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'
仔細查了之後才知道,是在讀取file時,用了以下這樣的code
仔細查了之後才知道,是在讀取file時,用了以下這樣的code
NSMutableDictionary *fileContent = [[[NSMutableDictionary alloc] initWithContentsOfFile:_filePath] autorelease];
_list = @"list";
_content = @"content";
_objects = [[fileContent objectForKey:_list] copy];
_qaDescriptions = [[fileContent objectForKey:_content] copy];
copy改成mutableCopy即可
沒有留言:
張貼留言