0

So I have the first class:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
    self.imageView.image = chosenImage;
    _camera_button.hidden = true;
    _camera_imageview.hidden = false;
    [_next_camera setEnabled:YES];
    NSData *imageData = UIImagePNGRepresentation(chosenImage);
    [self upload_selfie:imageData];

    [picker dismissViewControllerAnimated:YES completion:NULL];

}

And I am wanting to transfer the variable: imageData to this class:

- (IBAction)upload_selfie:(NSData *)sender{
    PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData];

    // Save PFFile
    [imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (!error) {
            // Hide old HUD, show completed HUD (see example for code)

            // Create a PFObject around a PFFile and associate it with the current user
            PFObject *userPhoto = [PFObject objectWithClassName:@"UserPhoto"];
            [userPhoto setObject:imageFile forKey:@"imageFile"];

            // Set the access control list to current user for security purposes
            userPhoto.ACL = [PFACL ACLWithUser:[PFUser currentUser]];

            PFUser *user = [PFUser currentUser];
            [userPhoto setObject:user forKey:@"user"];

            [userPhoto saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
                if (!error) {
//                    _loader6.hidden = true;
//                    [self performSegueWithIdentifier:@"toquestion" sender:self];
                }
                else{
                    // Log details of the failure
                    NSLog(@"Error: %@ %@", error, [error userInfo]);
                }
            }];
        }
    }];

}

Where I have tried:

PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:imageData];

But I receive the error "Use of undeclared identifier"?ces where I refrence imageData should I somewhere else?

Also these are the only two pla

Please may you explain why and what I can do about this?

user1806497
  • 65
  • 1
  • 7
  • please see my answer to this question [here][1] [1]: http://stackoverflow.com/questions/23036921/trying-to-save-text-and-output-it-on-different-screen/23073942#23073942 – Nick Apr 15 '14 at 18:20

2 Answers2

2

You receive this error because your variable name is sender:

- (IBAction)upload_selfie:(NSData *)sender

You need change your code to:

PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:sender];

PS. It seems that you use upload_selfie: method for two aims: a) interface builder action handler; b) method for saving photo. It is better to make two separate methods.

Vlad Papko
  • 13,184
  • 4
  • 41
  • 57
1

You're passing the parameter as sender so that's the name you should use: PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:sender];.

Though, to be more understandable, choosing a different name would be good.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57