NSInvalidArgumentException-不能将nil用于键或值

时间:2016-02-19 21:44:17

标签: objective-c mobile

我无法确定哪些对象正在返回一个nil对象,因为我已经在字典对象和对象键中提供了所有键。这是anypic应用程序的扩展,允许为图片设置位置。

 // create a photo object
PFObject *photo = [PFObject objectWithClassName:kPAPPhotoClassKey];
[photo setObject:[PFUser currentUser] forKey:kPAPPhotoUserKey];
[photo setObject:self.photoFile forKey:kPAPPhotoPictureKey];
[photo setObject:self.thumbnailFile forKey:kPAPPhotoThumbnailKey];
[photo setObject:self.eventLocation forKey:kFLocationKey];

// photos are public, but may only be modified by the user who uploaded them
PFACL *photoACL = [PFACL ACLWithUser:[PFUser currentUser]];
[photoACL setPublicReadAccess:YES];
photo.ACL = photoACL;

// Request a background execution task to allow us to finish uploading the photo even if the app is backgrounded
self.photoPostBackgroundTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
    [[UIApplication sharedApplication] endBackgroundTask:self.photoPostBackgroundTaskId];
}];

// save
[photo saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (succeeded) {
        NSLog(@"Photo uploaded");

        [[PAPCache sharedCache] setAttributesForPhoto:photo likers:[NSArray array] commenters:[NSArray array] likedByCurrentUser:NO];

        // userInfo might contain any caption which might have been posted by the uploader
        if (userInfo) {
            NSString *commentText = [userInfo objectForKey:kPAPEditPhotoViewControllerUserInfoCommentKey];

            if (commentText && commentText.length != 0) {
                // create and save photo caption
                PFObject *comment = [PFObject objectWithClassName:kPAPActivityClassKey];
                [comment setObject:kPAPActivityTypeComment forKey:kPAPActivityTypeKey];
                [comment setObject:photo forKey:kPAPActivityPhotoKey];
                [comment setObject:[PFUser currentUser] forKey:kPAPActivityFromUserKey];
                [comment setObject:[PFUser currentUser] forKey:kPAPActivityToUserKey];
                [comment setObject:commentText forKey:kPAPActivityContentKey];

                PFACL *ACL = [PFACL ACLWithUser:[PFUser currentUser]];
                [ACL setPublicReadAccess:YES];
                comment.ACL = ACL;

                [comment saveEventually];
                [[PAPCache sharedCache] incrementCommentCountForPhoto:photo];
            }
        }

0 个答案:

没有答案