无法在Parse中将NSMutableSet设置为PFObject键的值

时间:2015-04-03 20:53:16

标签: objective-c parse-platform nsset

每当在我的IOS应用程序中运行以下代码时,当我为NSFutableSet设置PFFobject键的值(下面标有“TROUBLE”的行)时,它就会神奇地停止运行。如果我设置一个断点,计算机就不会到达下一个断点。我甚至在Parse仪表板中添加了一个列,其中“peopleWhoFavorited”是一个Object类型,问题仍然存在。为什么?代码:

BOOL POSTING; //prevents repitious saving when user presses button multiple times.
-(void)post {

if (!(self.data==nil) && ![self.postField.text isEqualToString:@""] && !POSTING && ![self.postField.textColor isEqual:[UIColor grayColor]])   { //hackey with that grey color, but oh well.
    POSTING=YES;
    PFFile *file = [PFFile fileWithName:@"data" data:self.data];
    [file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            PFObject *post = [PFObject objectWithClassName:@"post"];
            [post setObject:@(0) forKey:@"voteScore"];
            [post setObject:@(0) forKey:@"numTimesReported"];
            [post setObject:@[] forKey:@"whoReported"];
            [post setObject:@[] forKey:@"comments"];

            //And now, the favorited sets and upvote and downvote sets...
            NSMutableSet * favoritedSet=[[NSMutableSet alloc] init];
            [post setObject:favoritedSet forKey:@"peopleWhoFavorited"]; "TROUBLE" //magical stopping point
            NSMutableSet * peopleWhoUpVoted=[[NSMutableSet alloc] init];
            //[post setObject:peopleWhoUpVoted forKey:@"peopleWhoUpVoted"];
            NSMutableSet * peopleWhoDownVoted=[[NSMutableSet alloc] init];
            //[post setObject:peopleWhoDownVoted forKey:@"peopleWhoDownVoted"];
            //
            //And a set for the people who report the post.
            NSMutableSet * peopleWhoReported=[[NSMutableSet alloc] init];
            //[post setObject:peopleWhoReported forKey:@"peopleWhoReported"];
            //
            [post setObject:self.postField.text forKey:@"postName"];
            [post setObject:self.dataTypeString forKey:@"postType"]; //either a movie or an image
            [post setObject:[NSDate date] forKey:@"dateMade"]; //hackey, equivalent of createdAt to avoid weird behaivor
            [post setObject:file forKey:@"data"];
            NSString * deviceIDString=[[[UIDevice currentDevice] identifierForVendor] UUIDString];
            [post setObject:deviceIDString forKey:@"deviceThatPosted"];

            [PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
                if (!error) {
                    // set the location of the post.

                    [post setObject:geoPoint forKey:@"location"];

                    //save the post in the background
                    [post saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
                        if (succeeded) {
                            NSLog(@"Saved.");
                            [self dismissViewControllerAnimated:YES completion:^{
                                NSLog(@"Posted and Dismiss completed");
                            }];
                            POSTING=NO;
                        } else {
                            NSLog(@"%@", error);
                            POSTING=NO;
                        }
                    }];
                } else{
                    NSLog(@"%@", error);
                    POSTING=NO;

                }
            }];


        } else {
            NSLog(@"%@", error);
            POSTING=NO;
        }
    }];

}

}

0 个答案:

没有答案