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

PFObjects

I am trying to set up a pfobject and every time i try to upload it it goes to the error found. I dont know what could be wrong.

'''- (IBAction)submitHours:(id)sender {

NSString *studentName = self.studentNameField.text;
NSString *grade = self.gradeField.text;
NSString *dramaPeriod = self.periodField.text;
NSString *crew = self.crewField.text;
NSString *timeIn = self.timeInField.text;
NSString *timeOut = self.timeOutField.text;
NSString *signature = self.phraseField.text;
NSString *numberOfHours = self.hoursField.text;

if ([studentName length]== 0|[grade length]== 0|[dramaPeriod length] == 0| [crew length] == 0| [timeIn length]==0|[timeOut length]== 0|[signature length] == 0| [numberOfHours length] == 0) {
    UIAlertView *alertview = [[UIAlertView alloc]initWithTitle:@"Oops" message:@"You have not put information into every field" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alertview show];
}else{
    self.hours = [[PFObject alloc]initWithClassName:@"Hours"];
    self.hours [@"Student name"] = self.studentNameField.text;
    self.hours [@"Grade"] = self.gradeField.text;
    self.hours [@"Drama Period"] = self.periodField.text;
    self.hours [@"Crew"] = self.crewField.text;
    self.hours [@"Time In"] = self.timeInField.text;
    self.hours [@"Time Out"] = self.timeOutField.text;
    self.hours [@"Signature"] = self.phraseField.text;
    self.hours [@"# Of Hours"] = self.hoursField.text;
    [self.hours saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (error) {
            NSLog(@"Uh oh, we couldn't even connect to the Parse Cloud!");
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Ooops" message:@"Please try again!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
            [alert show];
        }else{
            [self.navigationController popToRootViewControllerAnimated:YES];
        }
    }];



}

}'''

1 Answer

Stone Preston
Stone Preston
42,016 Points

you should probably log the error message so you can see whats actually going wrong

 if (error) {
            NSLog(@"Uh oh, we couldn't even connect to the Parse Cloud!");
            UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Ooops" message:@"Please try again!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
            [alert show];
            NSLog(@"error: %@ %@", error, error.userInfo);