我从 plist 加载了很多注释,所有加载都很好,但是如果我从 NSCachesDirectory 内存泄漏工具加载,则会显示泄漏。如果我从 url 加载,则不会泄漏。我在项目中使用 ARC。
内存泄漏
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *path = [[documentPaths lastObject] stringByAppendingPathComponent:@"test.plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path]; // leaking here
无泄漏
NSString *urlStr = [[NSString alloc]
initWithFormat:@"http://www.domain.com/test.plist" ];
NSURL *url = [NSURL URLWithString:urlStr];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfURL:url];