Im trying to build an app where the user inputs a number at a textfield and after pressing the button another view shows up with the result of that input.
Each number th
Since Library in this case is acting like your model it is your ViewController's responsibility to set and pull the data from it. The library does not (and should not) know anything about the ViewController class. This is a good solution to the problem you are facing:
So first, you will need a Library instance in your ViewController:
@interface ViewController ()
// Make sure you import library above
@property (strong, nonatomic) Library *library;
@end
Create the actual instance:
- (void)viewDidLoad {
[super viewDidLoad];
self.library = [Library new];
}
Then in your button click you should access your view's text field and set it on the library:
- (IBAction)showResultView:(id)sender {
self.library.number = [[self.fieldLabel text] intValue];
}