Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 选定表视图单元格的多维数组对象_Objective C_Arrays_Dictionary_Multidimensional Array - Fatal编程技术网

Objective c 选定表视图单元格的多维数组对象

Objective c 选定表视图单元格的多维数组对象,objective-c,arrays,dictionary,multidimensional-array,Objective C,Arrays,Dictionary,Multidimensional Array,我有一个数组字典,每个数组本身都有许多数组。它是字典中的多维数组 当我单击一个UItable行时,我会将视图推送到另一个类,但是我想与视图一起推,即对象键与单击的行名称相同的数组 我的代码如下 (执行推送操作的类) (视图被推送到的类) 正如您所见,有很多评论,因为我自己尝试了很多不同的方法。NSLog向您显示了foodObj或nil的内容?我希望它向我显示内容,但它只是使用无法识别的选择器发送到实例错误使应用程序崩溃..什么选择器到什么类? - (void)tableView:(UITable

我有一个数组字典,每个数组本身都有许多数组。它是字典中的多维数组

当我单击一个UItable行时,我会将视图推送到另一个类,但是我想与视图一起推,即对象键与单击的行名称相同的数组

我的代码如下 (执行推送操作的类)

(视图被推送到的类)


正如您所见,有很多评论,因为我自己尝试了很多不同的方法。

NSLog向您显示了foodObj或nil的内容?我希望它向我显示内容,但它只是使用无法识别的选择器发送到实例错误使应用程序崩溃..什么选择器到什么类?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic -- create and push a new view controller

if(dvController == nil) 
dvController = [self.storyboard instantiateViewControllerWithIdentifier:@"FoodCategoryView"];



//NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//NSMutableDictionary *keysAndObjects = [defaults objectForKey:@"keysAndObjects"];

Food *foodObj;

/*for (id key in [keysAndObjects allKeys]) {
    NSArray *foodArray = [keysAndObjects objectForKey:key];        
     foodObj = [foodArray objectAtIndex:indexPath.row];    
}*/

/*for (id key in [keysAndObjects allKeys]) {
    NSArray *foodArray = [keysAndObjects objectForKey:key];  
    for (Food *food in foodArray) {
        // do stuff with Food object
        //NSLog(@"%@", food.foodName);
    }
}*/


NSMutableArray *objects2   = [[NSMutableArray alloc] init];
NSMutableArray *objects1   = [[NSMutableArray alloc] init];
objects1 = [objects objectAtIndex:indexPath.row];  
objects2 = [objects1 objectAtIndex:indexPath.row];   
foodObj = objects2;

//NSLog(@"Object %@", [objects objectAtIndex:indexPath.row]);
NSLog(@"foodObj %@", foodObj);




//Get the detail view data if it does not exists.
//We only load the data we initially want and keep on loading as we need.
//[foodObj hydrateDetailViewData];

dvController.foodObj = foodObj;

[self.navigationController pushViewController:dvController animated:YES];

}
- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
}

/*for (Food *food in foodObj) {
    // do stuff with Food object
    NSLog(@"%@", food.foodName);
    cell.text = food.foodName;
}*/

//Food *food = [foodObj objectAtIndex:indexPath.row];
//cell.text = [foodObj objectAtIndex:indexPath.row];
cell.text = foodObj.foodName;
NSLog(@"%@", foodObj.foodName);

return cell;
}