RSS

Monthly Archives: June 2014

you can’t use self in block methods, use weakself reference to do so

__unsafe_unretained typeof(self) weakSelf = self;
[self.viewController setButton2Block:^(UIButton *button){
ViewController *obj_ViewController = [[ViewController alloc] initWithNibName:(IS_IPHONE_5)?@”ViewController_iPhone5″:@”ViewController” bundle:nil];
weakSelf.navigationController = [[UINavigationController alloc]
initWithRootViewController:obj_ViewController];
weakSelf.window.rootViewController = weakSelf.navigationController;
[weakSelf.window makeKeyAndVisible];
}];

 
Leave a comment

Posted by on June 13, 2014 in Uncategorized