Obj-C在主视图控制器中的应用程序启动时崩溃

时间:2015-08-04 20:33:18

标签: ios objective-c xcode cocoa-touch parse-platform

在我的项目中寻找一些调试帮助。我删除了额外的/已注释的代码,并且必须删除了应用程序基础的关键内容,因为它不再启动。

背景:该项目是构建一个[来自教育网站,团队树屋的一个受欢迎的克隆] [1]。应用程序名称是Ribbit,它通过使用Parse SDK获得其后端功能。

我添加了一个异常断点,看起来在InboxTableViewController中调用viewWillAppear时会发生一些错误,这是在启动时呈现给用户的主视图控制器。

如果有人能发现错误并就如何解决问题给我指导,我将非常感激。据我所知,

之后会出现一个问题
[query whereKey:@"recipientIDs" equalTo:[[PFUser currentUser] objectId]];

该应用程序是使用Xcode版本6.4(6E35b)构建的

项目链接:https://drive.google.com/file/d/0B1hfu8aguZOFUXVsbGNEQmdnMW8/view?usp=sharing

http://cl.ly/image/1n2c0G0P1Y1T/ "Link to screenshot of error log, with exception breakpoint"

1 个答案:

答案 0 :(得分:3)

你正在崩溃:

[query whereKey:@"recipientIDs" equalTo:[[PFUser currentUser] objectId]];

崩溃的原因是[PFUser currentUser]会在您的代码中返回nil

如果查看currentUser方法,文档会说:

/*!
 @abstract Gets the currently logged in user from disk and returns an instance of it.

 @returns Returns a `PFUser` that is the currently logged in user. If there is none, returns `nil`.
 */
+ (PF_NULLABLE instancetype)currentUser;

因此,要么登录,要么不要假定[PFUser currentUser]有效。