0

1 つの PFFile に 2 つのデータ (1 つの画像と 1 つのデータ サウンド) を保存したいと考えています。画像(fileData)はその通りですが、音データ(fileData2)の列をParse.comに追加したいと思います。どうすればこれを作ることができますか? できません: "PFFile *file = [PFFile fileWithName:fileName data:fileData,fileData2];"

これが私のコードです:

- (void)uploadMessage {
    NSData *fileData;
    NSData *fileData2;
    NSString *fileName;
    NSString *fileType;

    if (self.image != nil) {
        [SVProgressHUD showWithStatus:@"Sending..." maskType:SVProgressHUDMaskTypeClear];
        UIImage *newImage = [self resizeImage:self.image toWidth:320.0f andHeight:480.0f];
        fileData = UIImagePNGRepresentation(newImage);
        fileData2 = self.datasound;
        fileName = @"image.png";
        fileType = @"image";
    }

    PFFile *file = [PFFile fileWithName:fileName data:fileData];
    [file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (error) {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An error occurred!"
                                                                message:@"Please try sending your message again."
                                                               delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [SVProgressHUD dismiss];
            [alertView show];
        }
        else {
            PFObject *message = [PFObject objectWithClassName:@"Messages"];
            [message setObject:file forKey:@"file"];
            [message setObject:fileType forKey:@"fileType"];
            [message setObject:self.recipients forKey:@"recipientIds"];
            [message setObject:[[PFUser currentUser] objectId] forKey:@"senderId"];
            [message setObject:[[PFUser currentUser] valueForKey:@"name"] forKey:@"senderName"];
            [message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
                if (error) {
                    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"An error occurred!"
                                                                        message:@"Please try sending your message again."
                                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
                    [SVProgressHUD dismiss];
                    [alertView show];
                }
                else {
                    // Everything was successful!
                    [self reset];
                    [SVProgressHUD dismiss];
                }
            }];
        }
    }];
}
4

1 に答える 1