instantiateviewcontrollerwithidentifier泄漏

时间:2013-06-10 13:33:37

标签: iphone ipad ios5 memory memory-leaks

我对此代码感到沮丧......

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
    DoctorRecordController *object=[storyboard instantiateViewControllerWithIdentifier:@"DoctorRecord"];##############leaking code
    object.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:object animated:YES completion:^(void){            
    }];

仪器在上面的代码中显示泄漏。如何清除泄漏?

2 个答案:

答案 0 :(得分:0)

你正在你的街区捕捉对象。试试这个:

object.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:object animated:YES completion:^(void){
    object = nil;
}];

希望这有帮助。

答案 1 :(得分:0)

通过使用__block存储类型修饰符,我们可以使对象变为enter link description here http://kmithi.blogspot.de/2012/03/blocks-programming-in-ios.html