NSMutableDictionary设置值导致崩溃

时间:2012-06-05 15:14:13

标签: crash nsmutabledictionary

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];

0 个答案:

没有答案