我是新來的iOS開發人員。我正在製作一個應用程序,我從JSON獲取響應。但是當我點擊按鈕顯示下一個UITableView。 我有兩個問題給大家。因未捕獲異常'NSRangeException'而終止應用程序,原因:' - [__ NSCFArray objectAtIndex:]:index(14)beyond bounds(14)'
1)之前會顯示空值。我必須向下滾動顯示值。
2.)向下滾動調試錯誤後是節目 「終止應用程序由於未捕獲的異常 'NSRangeException',原因:「 - [__ NSCFArray objectAtIndex:]:索引(14)超出界限(14)」
對不起,我的英語不好。我可以說一點英語。
我們必須點擊按鈕才能進入下一個UITableView。
- (IBAction)btnf10
{
NSMutableDictionary *content = [NSMutableDictionary dictionary];
[content setValue:[[AppSetting sharedInstance] token] forKey:@"ewitoken"];
//[content setValue:gloablOnWherehouse.selectedWhereHouse forKey:@"model_Name"];
[[EWIConnector connector] requestEWIService:@"special_selected_f10" requestData:content delegate:self];
}
而requestEWIServiceStart將檢查字符串。
- (void) requestEWIServiceStart:(EWIConnector *)connector{
NSLog(@"start %@",connector.endpoint);
}
- (void) requestEWIServiceFinish:(EWIConnector *)connector responseData:(NSDictionary *)responseData{
NSLog(@"finish %@",connector.serviceName);
NSLog(@"response %@",responseData);
if ([connector.serviceName isEqualToString:@"special_selected_f10"])
{
NSLog(@"finish %@",connector.serviceName);
NSDictionary *content = responseData[@"content"];
NSString *stAlertMes = [content objectForKey:@"alertMessage"];
stAlertMes = [self getString:stAlertMes];
NSLog(@"AlertMSG : %@", stAlertMes);
if (![stAlertMes isEqualToString:@""]) {
NSLog(@"ALERT MESSAGE : %@", stAlertMes);
gloablOnWherehouse.arTableDataSelected = [[NSArray alloc] init];
}
else
{
NSLog(@"HAS DATA");
gloablOnWherehouse.arTableDataSelected = [content objectForKey:@"DataList_SPI_DetailCollection"];
[self.tableViewWhereHoseList reloadData];
labelStatus.text = @"F11";
}
}
else
{
NSLog(@"response %@",responseData);
}
}
UITableView 2用於響應數據。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
globlOnDisplayEffect = [GlobalVariable sharedInstance];
globlOnDisplayEffect.arTableDataSelectedWhereHouse = [[NSArray alloc] init];
[self.tableViewDetailList reloadData];
}
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return (globlOnDisplayEffect.arTableDataSelected)?[globlOnDisplayEffect.arTableDataSelected count]: 100;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"DisplayEffectQtyViewCell";
DisplayEffectQtyViewCell *cell = [self.tableViewDetailList dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath];
if(cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DisplayEffectQtyViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
} else {
if (globlOnDisplayEffect.arTableDataSelected) {
NSMutableArray *myMutbleArray = [[NSMutableArray alloc] init];
[myMutbleArray addObject:globlOnDisplayEffect.arTableDataSelected];
if (myMutbleArray) {
NSDictionary *myDic = [globlOnDisplayEffect.arTableDataSelected objectAtIndex:indexPath.row];
NSDictionary *cont = [myDic objectForKey:@"DataList_SPI_DetailF10"];
NSString *f10_cmpt = [self getString:[cont objectForKey:@"f10_cmpt"]];
NSString *f10_dt = [self getString:[cont objectForKey:@"f10_dt"]];
NSString *f10_item = [self getString:[cont objectForKey:@"f10_item"]];
NSString *f10_lot = [self getString:[cont objectForKey:@"f10_lot"]];
NSString *f10_model = [self getString:[cont objectForKey:@"f10_model"]];
NSString *f10_of = [self getString:[cont objectForKey:@"f10_of"]];
NSString *f10_semi = [self getString:[cont objectForKey:@"f10_semi"]];
NSString *f10_tm = [self getString:[cont objectForKey:@"f10_tm"]];
NSString *f10_uncmp = [self getString:[cont objectForKey:@"f10_uncmp"]];
[cell setf10_cmpt:f10_cmpt setf10_dt:f10_dt setf10_item:f10_item setf10_lot:f10_lot setf10_model:f10_model setf10_of:f10_of setf10_semi:f10_semi setf10_tm:f10_tm setf10_uncmp:f10_uncmp];
}
}
}
return cell;
}
添加異常斷點以查看發生錯誤的位置。 – RomOne
當我是異常斷點。它在 「DisplayEffectQtyViewCell * cell = [self.tableViewDetailList dequeueReusableCellWithIdentifier:simpleTableIdentifier forIndexPath:indexPath];」我從空白單元格向下滾動到單元格上的顯示值。 –