I have a class called Packet which responsible for receiving packets.
inside this class I want to change the view controller
the current view controller is: JoinViewController.
the class defined as
@interface Packet : NSObject
I have tried the following code but it doesn’t work here is code:
case PacketTypeMytype:
{
GameViewController *gameViewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
JoinViewController *join=[[JoinViewController alloc]initWithNibName:@"JoinViewController" bundle:nil];
[[join navigationController]pushViewController:gameViewController animated:YES];
You need to pass the instance of
JoinViewControllerto the packet object (as a weak reference) instead of creating a new one.