How i can start an other viewcontroller in a thread?
My code don't work:
- (IBAction)btnGotoNextVC:(id)sender
{
[self.isLoading startAnimating];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[NSThread detachNewThreadSelector:@selector(gotoSecondController:)
toTarget:self
withObject:[NSArray arrayWithObjects:@"hello there", nil]];
}
and my thread:
- (void) gotoSecondController: (NSArray*) parameters
{
NSString* data1 = parameters[0];
NSLog(@"%@", parameters[0]);
ViewController2 *VC2 = [self.storyboard instantiateViewControllerWithIdentifier:@"myView2"];
VC2.global_myLabel = [NSString stringWithFormat:@"Hallo %@", data1];
[self presentViewController:VC2 animated:YES completion:nil];
}
It's crashed by this line:
[self presentViewController:VC2 animated:YES completion:nil];
Error is:
-[NSStringDrawingContext animationDidStart:]: unrecognized selector sent to instance 0x8f983c0
What can i do? Thanks for answers!