Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.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
Ios 在核心数据应用程序中进行分段时,prepareForSegue崩溃_Ios_Objective C_Core Data_Segue - Fatal编程技术网

Ios 在核心数据应用程序中进行分段时,prepareForSegue崩溃

Ios 在核心数据应用程序中进行分段时,prepareForSegue崩溃,ios,objective-c,core-data,segue,Ios,Objective C,Core Data,Segue,我设置了一个tableViewController,用于在managedObjectContext中显示有关对象的数据。我没有从编译器那里得到任何错误,程序工作正常,直到我单击单元格中的UIButton来继续 我试图在managedObjectContext中选择与对象关联的纬度和经度值,并将这些值传递给另一个VC 这是我的prepareForSegue: - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

我设置了一个
tableViewController
,用于在
managedObjectContext
中显示有关对象的数据。我没有从编译器那里得到任何错误,程序工作正常,直到我单击单元格中的UIButton来继续

我试图在
managedObjectContext
中选择与对象关联的纬度和经度值,并将这些值传递给另一个VC

这是我的
prepareForSegue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"directionsSegue"]) {
        // Set destination view controller
        DirectionsViewController *destinationVC = segue.destinationViewController;

        // Pick out the "thing" you want to send to destinationVC
        CGPoint point = [sender convertPoint:CGPointZero toView:self.tableView];
        NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:point];
        NSLog(@"NSIndexPath *indexPath's index is %@", indexPath);

        // Set the "thing" on the destinationVC
        PointOfInterest *poi = [self.fetchedResultsController objectAtIndexPath:indexPath];
        destinationVC.destinationLatitude = poi.latitude;
        destinationVC.destinationLongitude = poi.longitude;

    }
}
这是我的控制台日志:

2015-03-15 12:01:18.449 BlocSpot[11680:832245] savedPOI managedObjectContext is <NSManagedObjectContext: 0x7fad650b1e60>
2015-03-15 12:20:12.719 BlocSpot[11680:832245] -[SavedPOITableViewController convertPoint:toView:]: unrecognized selector sent to instance 0x7fad62c6f640
2015-03-15 12:20:12.728 BlocSpot[11680:832245] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SavedPOITableViewController convertPoint:toView:]: unrecognized selector sent to instance 0x7fad62c6f640'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010955eb95 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000108e3dbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010956606d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00000001094bc1bc ___forwarding___ + 988
    4   CoreFoundation                      0x00000001094bbd58 _CF_forwarding_prep_0 + 120
    5   BlocSpot                            0x000000010836ae54 -[SavedPOITableViewController prepareForSegue:sender:] + 276
    6   UIKit                               0x000000010a0d471c -[UIStoryboardSegueTemplate _perform:] + 151
    7   BlocSpot                            0x000000010836ad1b -[SavedPOITableViewController directionButton:] + 91
它走得更远了一点,但还是崩溃了。这是日志:

2015-03-15 12:39:50.073 BlocSpot[11915:852339] savedPOI managedObjectContext is <NSManagedObjectContext: 0x7ffaac51d850>
2015-03-15 12:39:51.661 BlocSpot[11915:852339] NSIndexPath *indexPath's index is <NSIndexPath: 0xc000000000000016> {length = 2, path = 0 - 0}
2015-03-15 12:39:51.662 BlocSpot[11915:852339] -[UIButton view]: unrecognized selector sent to instance 0x7ffaac5eb330
2015-03-15 12:39:51.665 BlocSpot[11915:852339] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton view]: unrecognized selector sent to instance 0x7ffaac5eb330'

*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d2dbb95 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010cbbabb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010d2e306d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010d2391bc ___forwarding___ + 988
    4   CoreFoundation                      0x000000010d238d58 _CF_forwarding_prep_0 + 120
    5   BlocSpot                            0x000000010c0e7dcf -[SavedPOITableViewController prepareForSegue:sender:] + 207
    6   UIKit                               0x000000010de5171c -[UIStoryboardSegueTemplate _perform:] + 151
2015-03-15 12:39:50.073 BlocSpot[11915:852339]savedPOI managedObjectContext是
2015-03-15 12:39:51.661 BlocSpot[11915:852339]nsindepath*indepath的索引是{length=2,path=0-0}
2015-03-15 12:39:51.662 BlocSpot[11915:852339]-[UIButton视图]:发送到实例0x7ffaac5eb330的无法识别的选择器
2015-03-15 12:39:51.665 BlocSpot[11915:852339]***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIButton view]:无法识别的选择器发送到实例0x7ffaac5eb330'
***第一次抛出调用堆栈:
(
0 CoreFoundation 0x000000010d2dbb95例外预处理+165
1 libobjc.A.dylib 0x000000010cbbabb7 objc_异常_抛出+45
2 CoreFoundation 0x000000010d2e306d-[NSObject(NSObject)不识别选择器:][205
3 CoreFoundation 0x000000010d2391bc\uuuuuuuuuuuuuuuu+988
4 CoreFoundation 0x000000010d238d58\u CF\u转发\u准备\u 0+120
5 BlocSpot 0x000000010c0e7dcf-[SavedPOITableViewController prepareforsgue:sender:][207
6 UIKit 0x000000010de5171c-[UIStoryboardSegueTemplate]执行:][151
在这行中

CGPoint point = [sender convertPoint:CGPointZero toView:self.tableView];
您正在对
SavedPOITableViewController
调用
convertPoint:toView:
,但这不是视图控制器的方法,而是视图的方法。请尝试以下操作:

CGPoint point = [self.view convertPoint:CGPointZero toView:self.tableView];

谢谢你的关注。我更新了这篇文章。它前进了一点,但仍然崩溃。太棒了!我现在有一个双段,但我想我可以处理;)它传递了正确的值。非常感谢你!
CGPoint point = [self.view convertPoint:CGPointZero toView:self.tableView];