WriteToFile不在IOS中写入文件

时间:2014-02-18 11:44:32

标签: ios objective-c

更新

每当我注释掉这些行时,writeToFile会创建一个文件,但如果我不这样做,它将无效。

这是我的代码..

   NSMutableDictionary *allData = [[NSMutableDictionary alloc] init];

NSArray *countries = [self retrieveCountries];

for(NSDictionary *dicCountry in countries){
    NSString *countryName = [dicCountry objectForKey:@"en_name"];

    NSArray *capital = [self retrieveCapitals:countryName];

    NSMutableDictionary *capitalInfo = [[NSMutableDictionary alloc] init];
    for(NSDictionary *dictPerCap in capital){
        NSString *cap = [dictPerCap objectForKey:@"en_name"];
        NSArray *items = [self retrieveItems:cap];
        NSArray *categories = [self retrieveCategories:cap];

        if(items == nil)
            items = [[NSArray alloc] init];

        if(categories == nil)
            categories = [[NSArray alloc] init];

        // store data in a dictionary
        NSDictionary* tempCapDic = [NSDictionary dictionaryWithObjectsAndKeys:
                                    items, @"items",
                                    categories, @"categories",
                                    nil];

        //store
        [capitalInfo setObject:tempCapDic forKey:cap];
    }

    // store data in a dictionary
    NSDictionary* dataDic = [NSDictionary dictionaryWithObjectsAndKeys:
                             capital, @"capitals",
                             capitalInfo, @"info",
                             nil];

    //store
    [allData setObject:dataDic forKey:countryName];
}

/**************************/

NSDictionary *rootDict = [NSDictionary dictionaryWithObjectsAndKeys:countries, @"detailedCountries", allData, @"all", nil];

需要注释以便工作的行是:

capital, @"capitals",
capitalInfo, @"info",

在NSDictionary * tempCapDic中。 关于如何解决这个问题的任何想法?

0 个答案:

没有答案