I have a UIViewController(1), I press on a view in that controller and it then push's another UIViewController(2) with a full screen UITableView in it.
I then press on a cell in the UITableView and want to pass back to UIViewController(1) a string in the UITableView. I have tried using the below delegete method but it doesn't work, please can somebody advise.
UIViewController2.h
@protocol SecondDelegate <NSObject>
-(void) secondViewControllerDismissed:(NSString *)stringForFirst;
@end
@interface ViewController2 : UIViewController
{
id myDelegate;
}
@property (nonatomic, assign) id<SecondDelegate> myDelegate;
@end
and
UIViewController2.m (inside didSelectRowAtIndexPath)
[self.myDelegate secondViewControllerDismissed:@"the string I'm passing"];
and
UIViewController1.h
import "ViewController2.h"
@interface ViewController1 : UIViewController <SecondDelegate>
@end
and
UIViewController1.m
- (void)secondViewControllerDismissed:(NSString *)stringForFirst
{
NSString *myString = stringForFirst;
self.myLabel.text = myString;
}