my app crash with this message
011-02-22 00:12:30.422 test01[6246:207] -[RootViewController setString1:]: unrecognized selector sent to instance 0x623c800
2011-02-22 00:12:30.423 test01[6246:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RootViewController setString1:]: unrecognized selector sent to instance 0x623c800'
* Call stack at first throw:
this is my code:
- (void)save2:(id)sender{
(pseudoUtilisateur *) [pseudoUtilTb cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
self.string =textField.text;
NSLog(@"donnees %@",string);
AvisUtilisateur *avs = [self.navigationController.viewControllers objectAtIndex:0];
avs.string1 = self.string;
[self.n开发者_如何学编程avigationController popViewControllerAnimated:YES];
}
i dont understand why it told me RootviewController setString1. ?
thx
This line:
avs.string1 = self.string;
is translated by the compiler into this:
[avs setString1:[self string]];
You defined avs
as AvisUtilisateur *avs
so you're assuming the root view controller (the object at index 0 in the navigation controller's array of view controllers) is an instance of AvisUtilisateur
. Whether or not that's correct, your code assumes that the root view controller has a readwrite
property named string1
, and apparently that's not the case.
精彩评论