Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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 ipad splitview导航应用程序中DidSelectRowatineXpath中的indexPath null_Objective C_Ios_Ipad_Didselectrowatindexpath - Fatal编程技术网

Objective c ipad splitview导航应用程序中DidSelectRowatineXpath中的indexPath null

Objective c ipad splitview导航应用程序中DidSelectRowatineXpath中的indexPath null,objective-c,ios,ipad,didselectrowatindexpath,Objective C,Ios,Ipad,Didselectrowatindexpath,我正在将一个相当简单的基于iPhone导航的应用程序移植到一个拆分视图的iPad应用程序。 主视图上有两个嵌套的导航级别。用户从第一个表中选择一个值,然后加载第二个表。在第二个表上选择值将加载详图视图的详图项目。或者应该是这样。我的第二个控制器上的didSelectRowAtIndexPath正在启动,但indexPath为空 我非常关注SplitView模板。我添加了第二个TableViewController,这才真正脱离了常规。我的RootViewController在didSelectR

我正在将一个相当简单的基于iPhone导航的应用程序移植到一个拆分视图的iPad应用程序。
主视图上有两个嵌套的导航级别。用户从第一个表中选择一个值,然后加载第二个表。在第二个表上选择值将加载详图视图的详图项目。或者应该是这样。我的第二个控制器上的didSelectRowAtIndexPath正在启动,但indexPath为空

我非常关注SplitView模板。我添加了第二个TableViewController,这才真正脱离了常规。我的RootViewController在didSelectRowAtIndexPath上加载第二个TableViewController,该部分正在工作。在我的第二个TableViewController.m中,我试图为DetailView设置详细信息项。但这是didSelectRowAtIndexPath方法,它没有给我行。我对这一点相当陌生,但我觉得奇怪的是,单击一行的方法会触发,但没有该行的索引

代码如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    TrackerSplitViewAppDelegate *appDelegate = (TrackerSplitViewAppDelegate *)[[UIApplication sharedApplication] delegate];
    detailViewController.thisRequest = [appDelegate.requests objectAtIndex:indexPath.row];
    NSLog(@"Request Loaded: %@", detailViewController.thisRequest.Title);
    NSLog(@"Index Row: %@", indexPath.row);
    [appDelegate release];

}
请求数组正在正确加载(appDelegate.requests),但我的objectAtIndex失败,因为indexPath为null。或者至少indexPath.row为空

编辑:好的,下面的评论是正确的,我没有正确使用NSLog。行很好(我以为它在调试器中使用鼠标悬停时也显示为null,但我只是不知道如何正确使用调试器)

由于某些原因,detailViewController属性设置不正确。如果我将其替换为:

//detailViewController.thisRequest = [appDelegate.requests objectAtIndex:indexPath.row];
Request *aRequest = [appDelegate.requests objectAtIndex:indexPath.row];
aRequest对象加载得很好。因此,下一个问题是为什么在detailViewController对象上设置我的属性不起作用。我还不清楚在这种环境下事情是如何持续的。任何额外的投入都会很好

NSLog(@“索引行:%@”,indexath.Row)

indexPath是NSIndexPath对象,您可以使用%@打印它。
但是indexPath.row和indexPath.section是整数。所以您必须使用%u来打印它们

因此,您的indexpath.row可能不是nil(与no对象一样),而是0(与0一样,是1之前的数字)


选择一个不是第一行的行,应该会发生崩溃

NSLog(@“索引行:%@”,indexath.Row)

indexPath是NSIndexPath对象,您可以使用%@打印它。
但是indexPath.row和indexPath.section是整数。所以您必须使用%u来打印它们

因此,您的indexpath.row可能不是nil(与no对象一样),而是0(与0一样,是1之前的数字)



选择一个不是第一行的行,您应该会遇到崩溃。

indexPath的值。行不是字符串。您不能使用
%@
记录它。尝试使用用于整数的
%i
%li
。另外,您还没有真正正确地检查要加载的请求。
title
属性是否仅在成功加载后可用?

indexPath.row的值不是字符串。您不能使用
%@
记录它。尝试使用用于整数的
%i
%li
。另外,您还没有真正正确地检查要加载的请求。
标题
属性是否仅在成功加载后可用