Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access a property declared in a viewController which is assigned to UINavigationController?
    primarykey
    data
    text
    <p>I am trying to implement a application which has five tabs totally. Each of tabs corresponds to a view controller, such as viewController1~viewController5.</p> <p>For the viewController4, I add the navigationController on it in AppDelegate.m as following:</p> <pre><code>viewController4 = [[iPhone_ASRAViewController alloc] initWithNibName:@"iPhone_ASRAViewController_iPhone" bundle:nil]; navController1 = [[UINavigationController alloc]initWithRootViewController:viewController4]; </code></pre> <p>In the iPhone_ASRViewController class, I have declared a property in .h file as following:</p> <pre><code> @property (nonatomic, retain) NSString *student_id; </code></pre> <p>Then, I want to access the student_id(set the student_id) which is declared in iPhone_ASRViewController in the FirstViewController, and implement in FirstViewController.m as following:</p> <pre><code>iPhone_ASRAViewController *iphone_ASRAVC= [self.tabBarController.viewControllers objectAtIndex:3]; iphone_ASRAVC.student_id=[stu_class stringByAppendingString:stu_id]; //stu_class and stu_id is the text field declared in the FirstViewController. </code></pre> <p>Ideally, when a certain button which is implemented in the FirstViewController class is pushed by users, the value of student_id will also be set to iPhone_ASRAViewController class.</p> <p>Unfortunately, the app will crash when users push the button. Error msgs as following:</p> <pre><code>[UINavigationController setStudent_id:]: unrecognized selector sent to instance 0x9341170 </code></pre> <p>Can someone provide me with some ideas/solutions to debug, please?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload