Ios 在一个文件中获取两个数据

Ios 在一个文件中获取两个数据,ios,objective-c,parse-platform,pffile,Ios,Objective C,Parse Platform,Pffile,我想在一个文件中保存两个数据:一个图像和一个声音数据。 这对于图像(fileData)是正确的,但是我想在Parse.com中为数据声音(fileData2)添加一列。我怎么做这个?我做不到:“PFFile*file=[PFFile fileWithName:fileName-data:fileData,fileData2];” 这是我的密码: - (void)uploadMessage { NSData *fileData; NSData *fileData2; NSS

我想在一个文件中保存两个数据:一个图像和一个声音数据。 这对于图像(fileData)是正确的,但是我想在Parse.com中为数据声音(fileData2)添加一列。我怎么做这个?我做不到:“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];
                }
            }];
        }
    }];
}
你不能(轻易地)把两个文件放进一个文件里。PFFFile表示一个文件

制作两个PFFile实例,一个用于图像,一个用于声音文件

PFFile *imageFile = [PFFile fileWithName:imageFileName data:imageFileData];
PFFile *soundFile = [PFFile fileWithName:soundFileName data:soundFileData];
将PFFile的这些实例设置为相应的解析列。例如:

[message setObject:imageFile forKey:@"imageFile"];
[message setObject:soundFile forKey:@"soundFile];