We have some Bluetooth class, that creates connection to a bluetooth module .
As long as this class is alive, the connection is alive .
We are creating that class instance, in viewA
.
Than when we go to viewB
,we would like to keep the BL class alive, by passing it to the next view , viewB
.
How would we do that (without singleton ,just passing it,or using app delegate)
in viewA
:
//creating the instance of the BL class
self.bluetooth=[[BLEModule alloc] init];
self.bluetooth.delegate=self;
...
....
//go the next view-viewB (now pass that instance self.bluetooth to viewB)
UIViewController *next=[[CallTestView alloc]init];
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[UIView transitionFromView:delegate.window.rootViewController.view
toView:next.view
duration:1.5f
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished)
{
delegate.window.rootViewController=next;
}];