ios - 更新 Parse 对象时在代码内部发出警告

标签 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 的行中,有一个错误警告(应为“:”),但我找不到原因。

欢迎任何帮助。

最佳答案

从表面上看,您从未关闭查询括号:

PFQuery getObjectInBackground.... {

但从未使用正确的语法关闭它,或者看起来您有一个额外的括号 }。为了更好地练习,您应该在 if 语句中使用适当的缩进,否则可能会像这样发生复杂情况。你迷失在代码中,因为你不知道语句从哪里开始或结束

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

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

我无法排除故障,因为我在使用 iPhone,但我建议返回并使用适当的缩进,这样您就可以捕获罪魁祸首

关于ios - 更新 Parse 对象时在代码内部发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28620093/

相关文章:

ios - 在等待来自 Parse 的数据时,使用 swift 显示加载动画

iphone - 如何在编写漂亮代码的同时避免扩展 NSArray 和在 Java 中思考

ios - 从命令行将静态库添加到 xcode 项目

objective-c - 单击按钮时如何传递对象

swift - PFQuery 中的逻辑运算符错误

ios - 使用 swift 查找现有 PFUser

android - 解析服务器 : Can not find sender for push type android

ios - 使用 UIKeyCommand 时如何处理大写和小写字符

android - 使用网页链接访问移动 GPS 应用程序并将当前位置传递给应用程序

xcode - 检查 Parse.com 中是否存在图像