0

plistファイルのコンテンツを読み取るには、ARCを使用しない方法があります。

-(void)readAppFile
{
    NSString *plistPath = [self getDataFileDestinationPath];
    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
    NSString *errorDesc = nil;
    NSPropertyListFormat format;
    NSMutableDictionary *temp = (NSMutableDictionary *) [NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
    if (!temp) {
        NSLog(@"Error reading plist: %@, format: %d", errorDesc, format);
    }
    items = [[temp objectForKey:@"Items"] mutableCopy];
    NSLog(@"Read file!");
}

ここで大きなメモリ リークが発生しました。そのため、コードの最後をこの行に置き換えましたitems = [[[temp objectForKey:@"Items"] mutableCopy] autorelease];が、今はThread 1: EXC_BAD_ACCESS (code=1, addres=0x6000000008). 今日は、この方法をどうするか分からない2日目です。

4

1 に答える 1