Are there alternatives to \"delegates\" to pass back data from one controller to another?
Just seems like a lot of work implementing a delegate just to pass back the
You could use many ways:
Example for for 1.
interface of your MainViewController: add a public method for the data to be passed
- (void)newDataArrivedWithString:(NSString *)aString;
MainViewController showing ChildController
- (void)showChildController
{
ChildController *childController = [[ChildController alloc] init];
childController.mainViewController = self;
[self presentModalViewController:childController animated:YES];
[childController release];
}
Child Controller header / interface: add a property for the mainViewController
@class MainViewController;
@interface ChildController : UIViewController {
MainViewController *mainViewController;
}
@property (nonatomic, retain) MainViewController *mainViewController;
Child Controller passing data to the MainViewController
- (void)passDataToMainViewController
{
NSString * someDataToPass = @"foo!";
[self.mainViewController newDataArrivedWithString:someDataToPass];
}