Ray Wenderlich的Mapkit教程中的SIGABRT

时间:2012-12-23 21:34:40

标签: ios objective-c iphone ios6

所以我跟随Ray Wenderlich的Mapkit教程here。我被困在我应该使用plotCrimePositions方法在地图上绘制罪行的部分。使用调试器,我已将其缩小到我创建NSDictionary* root的位置,但似乎无法找到错误。任何帮助将不胜感激。 Here is a gist with relevant files.

谢谢!

编辑:这是我的控制台日志:

2012-12-23 16:31:52.925 MapTutorial[8993:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
*** First throw call stack:
(0x1850012 0x1645e7e 0x184fdeb 0x117a817 0x34697 0x35153 0x1659705 0x590920 0x7ccb24 0x1659705 0x590920 0x5908b8 0x651671 0x651bcf 0x650d38 0x5c033f 0x5c0552 0x59e3aa 0x58fcf8 0x223bdf9 0x223bad0 0x17c5bf5 0x17c5962 0x17f6bb6 0x17f5f44 0x17f5e1b 0x223a7e3 0x223a668 0x58d65c 0x341cd 0x2945)
libc++abi.dylib: terminate called throwing an exception

1 个答案:

答案 0 :(得分:1)

你的问题在这里:

- (IBAction)refreshTapped:(id)sender{
    //...
    [request startAsynchronous]; //Start the request
    [self plotCrimePositions:request.responseData]; //Assume there's data, 
    //despite the request not even have been given a chance to start
}

因为您假设您的request将同步执行,然后在完成时转到plotCrimePositions:,您认为请求获得的数据是非零的(显然不是这种情况),导致MapKit翻转。如果您将[self plotCrimePositions:request.responseData];移动到您指定的完成处理程序的范围内,它应该像魅力一样工作。异步请求是异步的:意味着它们会立即返回,这就是为什么完成块是天赐之物。