Skip to content

Instantly share code, notes, and snippets.

@casspangell
Last active August 29, 2015 14:11
Show Gist options
  • Save casspangell/8ef7dfa9edd17c0c98d4 to your computer and use it in GitHub Desktop.
Save casspangell/8ef7dfa9edd17c0c98d4 to your computer and use it in GitHub Desktop.
@protocol NavBarDelegate <NSObject>
@optional
- (void)changeDashboardButton :(NSString*)fromSegue;
@end
@property (nonatomic,strong) id<NavBarDelegate> navbarDelegate;
@interface NavigationBar : UIView <NavBarDelegate> {
AppDelegate* appDelegate;
}
-(id) initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame])
{
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.navbarDelegate = self;
}
self.frame = frame;
return self;
}
- (void)changeDashboardButton :(NSString*)data{
NSLog(@" data %@", data);
}
- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[self setUpView:@"Yo"]; //Totally works
[self test];//Totally breaks unrecognized selector sent to instance 0x7869d8d0
}
- (void) setUpView:(NSString*)sData{
[appDelegate.navbarDelegate changeDashboardButton:sData];
}
-(void)test {
[appDelegate.navbarDelegate changeDashboardButton:@"Hello"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment