I am trying to press string text to view controller 1 from my view manager 2 using protocols and delegate. I'm new to this data transfer method, so forgive me if I seem kind of ignorant. The color of the string always returns null. I will post the code that I still have, and if that helps, im using the navigation controller and using the navigation button go from ViewController 2 to ViewController 1.
Viewcontroller 2
.h
@protocol PassString <NSObject> @required - (void) setSecondFavoriteColor:(NSString *)string; @end @interface ViewController2 : UIViewController{ UIButton *button; NSString *ee id <PassString> delegate; } @property (retain) id delegate;
ViewController 2
.m
@synthesize delegate; -(void)button{ ee = @"Blue Color"; [[self delegate] setSecondFavoriteColor:ee];
ViewController 1.h
@interface ViewController1 : UIViewController <PassString>{ NSString*color; } @property (strong,nonatomic) NSString *color
ViewController 1.m
- (void)setSecondFavoriteColor:(NSString *)string { color = string; NSLog(@"%@",color); }
source share