I'm currently having some trouble with data getting lost when transferring from a ViewController to a subclass of PFFile. The data being passed is image data to upload to a users profile. Here's the code for selecting the image:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { // Access the uncropped image from info dictionary UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; // Dismiss controller [picker dismissViewControllerAnimated:YES completion:nil]; // Resize image _focusedImage.image = image; NSData *imageData = UIImageJPEGRepresentation(image, 0.05f); PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData]; [[imageUpload uploadImage] setImagePFFile:imageFile]; } The Log on imageFile in this view is printing out correctly. However, when I pass the data through to my singleton class imageUpload uploadImage This is what the data structure looks like:
+ (imageUpload *) uploadImage { static imageUpload*_sharedImageUpload = nil; _sharedImageUpload = [[self alloc] init]; _sharedImageUpload.imageData = [[NSData alloc] init]; PFUser *user = [PFUser currentUser]; _sharedImageUpload.imagePFFile = [[PFFile alloc] init]; PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:_sharedImageUpload.imageData]; [imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (!error) { [user setObject:imageFile forKey:@"image"]; [user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) { if (!error) { NSLog(@"This should be the profile image upload"); } else { NSLog(@"Something went wrong: %@", error); } }]; } }]; return _sharedImageUpload; } When I get to this point, the system just uploads a blank file (zero bytes) to Parse. The naming is right and its going in the right place on the database, but somewhere along the line the data in the file itself is being lost. I can't figure out why. Does anyone have any suggestions?