Reputation: 670
during the prepareForSegue I try to assign a value to property and get the error
2012-05-09 23:14:22.122 LeakSpotter[17709:15b03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setCoordLong:]: unrecognized selector sent to instance 0xa86e930'
header:
@property (nonatomic, retain) NSString *CoordLong;
@property (nonatomic, retain) NSString *CoordLat;
They are sythesized.
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"Fired segue %@", [segue identifier]);
if([[segue identifier] isEqualToString:@"returnToLeakSpotter"]){
NSLog(@"Return to leak spotter segue...");
//ContactsViewController *cvc = (ContactsViewController *)[segue destinationViewController];
}else if ([[segue identifier] isEqualToString:@"gotoTakePhoto"]) {
NSLog(@"Go to photo view");
takePhotoViewController *takePhotoC = [segue destinationViewController];
takePhotoC.CoordLong = @"-9.88";
takePhotoC.CoordLat = @"45.45";
Have I missed something obvious?
Thanks
Upvotes: 0
Views: 1890
Reputation: 18551
You may need to cast your viewController since destinationViewController returns a UIViewController by default.
takePhotoViewController *takePhotoC = (takePhotoViewController *)[segue destinationViewController];
Upvotes: 0
Reputation: 119242
Looks like you haven't set the view controller subclass on your takePhotoViewController in the storyboard, so it is instantiating a base UIViewController (as seen in the error) which doesn't know what CoordLat is.
By the way, by convention class names start with an upper case letter and variables/properties with a lower case letter, you seem to have it the other way round.
Upvotes: 4