Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 与popToViewController共享数据_Objective C_Xcode_Ios4 - Fatal编程技术网

Objective c 与popToViewController共享数据

Objective c 与popToViewController共享数据,objective-c,xcode,ios4,Objective C,Xcode,Ios4,我的应用程序因此消息而崩溃 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 'NSInvalidArgumentExcepti

我的应用程序因此消息而崩溃

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'
*第一次抛出时调用堆栈:

这是我的代码:

- (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.navigationController popViewControllerAnimated:YES];
}

我不明白为什么它告诉我RootviewController setString1

thx这一行:

avs.string1 = self.string;
由编译器转换为:

[avs setString1:[self string]];

您将
avs
定义为
AvisUtilisateur*avs
,因此假设根视图控制器(导航控制器视图控制器数组中索引0处的对象)是
AvisUtilisateur
的实例。无论这是否正确,您的代码都假定根视图控制器具有名为
string1
readwrite
属性,显然情况并非如此。

您好,谢谢您的回答。但我不明白为什么我必须在rootViewControll中声明string1。我不想在rootViewController中共享数据。可能是因为我使用了[self.navigationController.viewControllers]?我有3个类:rootViewController、AvisUtilisateur和PseudoUtilisateur。我想在PseudoUtilisateur和AvisUtilisateur之间共享数据。thxy您的代码正在向自定义类
RootViewController
的实例发送
setString1:
消息,该实例是导航控制器内索引0处的对象。也许您希望它是
AvisUtilisatuer
的一个实例,但事实并非如此。