我正在尝试从Parse下载图像,当我完成从解析程序下载所有图像时我的程序崩溃并出现错误:
NSNull getDataInBackgroundWithBlock:progressBlock:]:发送到实例的无法识别的选择器.
我试过添加一些条件,如
if(![object objectForKey:@"goal_image"]) //If it is nil => exit
Run Code Online (Sandbox Code Playgroud)
但它仍在崩溃.这是我的代码:
PFQuery *query = [PFQuery queryWithClassName:@"Goal"];
[query getObjectInBackgroundWithId:[object objectId] block:^(PFObject *object, NSError *error) {
if(!error)
{
PFFile * imageFile = [object objectForKey:@"goal_image"];
if (imageFile) {
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error2) {
if (!error2) {
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Images/Goals/%@",[object objectId]]];
[data writeToFile:jpgPath atomically:YES];
}
} progressBlock:^(int percentDone) {
if (percentDone == 100) {
NSLog(@"Download Completed");
}
}];
}
}
}];
Run Code Online (Sandbox Code Playgroud) 我正在从Parse中正确检索我的数据,但是当试图调用函数getCreatedAt时它不起作用.
我正在检索这样的其他信息:
$obj->get(' description');
Run Code Online (Sandbox Code Playgroud)
但是当调用getCreatedAt时,页面不起作用并抛出此错误:
__toString() must not throw an exception
Run Code Online (Sandbox Code Playgroud)
我试过这样的时间戳
$obj->get('createdAt');
$obj->getCreatedAt();
Run Code Online (Sandbox Code Playgroud)
但都没有效果.
有谁知道可能会发生什么?