NSMutableDictionary *firstCurr;
NSLog(@"currency list count=%d",[self.currencyList count]);
for (int j=0; j<[self.currencyList count]; j++)
{
NSLog(@"j=%d",j);
firstCurr = [self.currencyList objectAtIndex:j];
[firstCurr setValue:[NSNumber numberWithFloat: [[currencyItems objectAtIndex:j]floatValue]] forKey:kSelectedCurrencyINR];
}
我有一组称为货币列表的 nsmutabledictionary 对象,我正在尝试设置 nsmutabledictionary 的一个字段。访问标记行中的 firstCurr 会导致崩溃!
NSMutableArray *arr;
arr = [[[NSMutableArray alloc] init] autorelease];
[[NSUserDefaults standardUserDefaults] setObject:arr forKey:kSelectedCurrencies];
这就是我在数组中添加的方式
NSDictionary *dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setValue:countryCode[pos] forKey:kSelectedCurrencyCode];
[dict setValue:countryName[pos] forKey:kSelectedCurrencyCountry];
[dict setValue:[NSNumber numberWithFloat:2.0] forKey:kSelectedCurrencyINR];
[dict setValue:currencyName[pos] forKey:kSelectedCurrencyName];
[temp addObject:dict];
[[NSUserDefaults standardUserDefaults] setObject:temp forKey:kSelectedCurrencies];
[[NSUserDefaults standardUserDefaults] synchronize];