Thursday, 23 July 2015

How to navigate to a ViewController from NSObject Class in iOS

NSObject file:

.h

@interface NotificationTap : NSObject


-(void)SingleViewController:(UINavigationController *)nav msg:(NSDictionary*)note;

.m

-(void)SingleViewController:(UINavigationController *)nav msg:(NSDictionary*)note
{
    ChatViewController *viewController = [[ChatViewController alloc] init];
    [nav pushViewController:viewController animated:YES];
}

ViewController File:

.h

#import "NotificationTap.h"
@property(nonatomic,retain) NotificationTap *callView;


-(void)callSingleChat:(NSNotification *)note{
    self.callView = [[NotificationTap alloc] init];
    [self.callView SingleViewController:self.navigationController msg:note.object];
}


No comments:

Post a Comment