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!
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
Elizabeth Hill
1,147 PointsRibbit
The Ribbit app crashed when I clicked the send button in the Camera View Controller. The output said
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't use nil for keys or values on PFObject. User NSNull for values.'
- (IBAction)send:(id)sender {
if (self.image == nil && [self.videoFilePath length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Try again" message:@"Please capture or select a video or photo to share" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[self presentViewController:self.imagePicker animated:NO completion:nil];
}
else {
[self uploadMessage];
[self reset];
[self.tabBarController setSelectedIndex:0];
}
3 Answers

miles fishman
Courses Plus Student 3,610 Pointsremove [self reset]; from the else condition

miles fishman
Courses Plus Student 3,610 Pointsand make sure you have extra closing bracket at the end

miles fishman
Courses Plus Student 3,610 Pointsyou are missing one in the code you posted should look like this:
- (IBAction)send:(id)sender {
if(self.image==nil &&[self.videoFilePath length]==0){
UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"Try again!" message:@"Please capture or select picture or video" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
[self presentViewController:self.imagepicker animated:NO completion:nil];
}
else{
[self uploadMessage];
[self.tabBarController setSelectedIndex:0];
}
}
Thomas Numan
2,241 PointsI am having the exact same problem outlined by Elizabeth/ What was stated above by Miles unfortunately didn't help as i already had deleted [self reset]; long ago.. What is the issue here?
-
(IBAction)send:(id)sender { if (self.image == nil && [self.videoFilePath length]== 0) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Try again" message:@"Please capture or select a photo or video to share!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show]; [self presentViewController:self.imagePicker animated:NO completion:nil];
} else { [self uploadMessage];
[self.tabBarController setSelectedIndex:0];
} }