2017-05-26 40 views
0

我做了一個保留週期,但在剖析中,這些工具似乎找不到這個明顯的保留週期XCode的內存配置文件工具無法檢測到這種保留週期?

首先,ViewController將保留SubViewController作爲屬性subVC,並將其設置爲SubViewController的委託。

@interface ViewController()<TestDelegate> 
@property(nonatomic,strong) UIViewController* subVC; 
@end 

@implementation ViewController 

- (void)dealloc 
{ 
    NSLog(@"ViewController dealloc"); 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 


- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 
{ 
    SubViewController* subVC = [[SubViewController alloc] init]; 
    subVC.delegate = self; 
    self.subVC = subVC; 
    [self presentViewController:subVC animated:YES completion:nil]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (void)didSelect 
{ 

} 
@end 

而在SubViewController的委託被設置爲強屬性保留委託

@protocol TestDelegate <NSObject> 
@optional 
- (void)didSelect; 
@end 

@interface SubViewController : UIViewController 
@property(nonatomic,strong) id<TestDelegate> delegate; 
@end 

@interface SubViewController() 

@end 

@implementation SubViewController 

- (void)dealloc 
{ 
    NSLog(@"SubViewController dealloc"); 
} 

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 
{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view. 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

/* 
#pragma mark - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 
} 
*/ 

@end 

回答

0

OK,現在這些工具似乎工作只要我的所有堆之間的面板之間切換&泄漏檢查。如果我不切換它們。保留週期永遠不會被發現。 enter image description here