Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Making an object that contains a user

Hi there,

I'm trying to implement a friend request system in an app I'm working on, and for some reason, I can't save a PFUser object in an object I create...How do I get around this/fix this?

This is my code to simply get the user saved into the object FriendRequest2:

PFObject *friendRequest = [PFObject objectWithClassName:@"FriendRequest2"];
    friendRequest[@"user"] = [PFUser currentUser];

    [friendRequest saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

        if (succeeded) {


            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Yay" message:@"Friend request sent" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
            [alert show];



        } else {

            NSLog(@"user was not saved");
        }
    }];


//When I run this, "user was not saved" is displayed, and nothing is saved in parse.

Mod Edit: Edited your code block to include all your code and add syntax highlighting - Patrick