iOS UIPickerView加载数据,错误

时间:2012-01-22 12:54:21

标签: ios uipickerview

我必须将数据保存在一个页面上,然后将它们上传到另一个页面。为此,我使用单身人士。我有NSMutableArray。我通过这段代码保存数据

NSData *datPredmet = [NSKeyedArchiver archivedDataWithRootObject:[Singleton sharedInstance].arrayPredmet];
[[NSUserDefaults standardUserDefaults] setObject:dataPredmet forKey:@"predm"];

然后我加载这些数据,如下所示

NSData *dataPredmet = [[NSUserDefaults standardUserDefaults] objectForKey:@"predm"];
NSArray *arrPredmet = [NSKeyedUnarchiver unarchiveObjectWithData:dataPredmet]; 
[Singleton sharedInstance].arrayPredmet=[NSMutableArray alloc]init]; 

for(int i=0; i<[arrPredmet count]; i++)
{   
  [[Singleton sharedInstance].arrayPredmet addObject:[arrPredmet objectAtIndex:i]];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow: (NSInteger)row inComponent:(NSInteger)component {

   tempPredmet=[[Singleton sharedInstance].arrayPredmet objectAtIndex:row];
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {

   return [[Singleton sharedInstance].arrayPredmet count];
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {

   return [[Singleton sharedInstance].arrayPredmet objectAtIndex: row];    
}

当我点击按钮拨打UIPickerView时,我收到此错误

  

在抛出'NSException'实例后终止调用

0 个答案:

没有答案