0

I'm new here and new to iOs programming too. I'm creating a math app. My app now has some viewcontrollers which perform different calculation, and I want to save results from each viewcontroller to a new viewcontroller(ResultViewController) and make the saved data accessible from another viewcontroller.

I've read Passing Data between View Controllers and tried to push data to a navigating stack but ended up with "Could not load NIB in bundle".

ResultViewController *resultVC = [[ResultViewController alloc] initWithNibName:@"ResultViewController" bundle:nil];
resultVC.resultString = msg;
[self.navigationController pushViewController:resultVC animated:YES];

Besides I'm not sure whether this can make the saved data accessible from the other classes??

Another problem I'm facing is when we access a viewcontroller and go back to the same page, all data in the same page will be reset(I want to keep the data). So should I leave the ResultViewController and change to another object?? Or do you know other methods for this??

Thank you and excuse me for my English. :)

Community
  • 1
  • 1
user
  • 85
  • 3
  • 13

1 Answers1

0

I would highly recommend to read WorkingwithObjects - Developer.Apple and communication-patterns instead of 'Passing Data between View Controllers' before you start.

Tryout the examples and identify some best-practice recommendations regarding when you should use which mechanism.

Could not load NIB in bundle

The error means that there is no .xib file with the name ResultViewController. Cross check the .xib file name again. Also look at the Target -> Buid Phases -> Copy Bundle Resources to see the .xib file is in red colour.

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102