更新Parse对象时代码内的警告

时间:2015-02-20 01:14:23

标签: ios parse-platform

我使用以下代码将Parse对象更新为按钮操作:

-(IBAction)sendPressed:(id)sender
{


    NSLog(@"boton subir cadena pulsado");
    loadingSpinner.hidden = NO;
    [loadingSpinner startAnimating];

    //Upload a new picture
    NSData *pictureData = UIImagePNGRepresentation(self.chainPhoto.image);

    PFFile *file = [PFFile fileWithName:@"img" data:pictureData];
    [file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

        if (succeeded){
            NSLog(@"IMAGEN CARGADA");

            PFQuery *query = [PFQuery queryWithClassName:@"cadenas"];

            // Retrieve the object by id
            [query getObjectInBackgroundWithId: chain.objectId block:^(PFObject *imageObject, NSError *error)
             {

            [imageObject setObject:file forKey:@"image"];




            [imageObject setObject:self.commentTextField.text forKey:@"chain_name"];


            [imageObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

                if (succeeded){
                    //Go back to the wall
                    [self.navigationController popViewControllerAnimated:YES];
                }
                else{
                    NSString *errorString = [[error userInfo] objectForKey:@"error"];
                    [self showErrorView:errorString];
                }
            }];
        }

       ERROR HERE--> else
            {
            NSString *errorString = [[error userInfo] objectForKey:@"error"];
            [self showErrorView:errorString];
        }

             }
        [loadingSpinner stopAnimating];
        //loadingSpinner.hidden = YES;
        //self.commentTextField.text =@" ";
        self.progress_block.hidden = YES;

       // self.imageView.image = [UIImage imageNamed:@"no-image.jpg"];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Restaurant Chain changed with success"
                                                        message:@"You can now go back to the list."
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];



    } progressBlock:^(int percentDone) {


        self.progress_block.hidden =NO;
        self.progress_block.progress = (float) percentDone/100+progressValue;


    }];

}

在我在代码中标记为ERROR HERE的行中,出现错误警告(预期":"),但我无法找到原因。

欢迎任何帮助。

1 个答案:

答案 0 :(得分:1)

从它的外观来看,你从未关闭查询括号:

PFQuery getObjectInBackground.... {

但从未使用正确的语法关闭它,或者看起来你有一个额外的括号}。为了更好的练习,你应该使用if语句进行适当的缩进,否则就会发生并发症。您在代码中迷失了,因为您不知道语句的开始或结束位置

你应该在else语句之后关闭它:

    } ERROR HERE--> else {
        NSString *errorString = [[error userInfo] objectForKey:@"error"];
        [self showErrorView:errorString];
        //stop animating and other stuff
    }
}];

我无法排除故障,因为我在我的iPhone上,但我建议回去使用适当的缩进,这样你才能抓住罪魁祸首