出现了标题的错误
查了一通,内存管理的问题
http://stackoverflow/questions/9286782/potential-leak-of-an-object-allocated-and-stored-into-annot
https://developer.apple/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html
这个例子很好:
You could also implement the fullName
method like this:
- (NSString *)fullName { |
NSString *string = [NSString stringWithFormat:@"%@ %@", |
self.firstName, self.lastName]; |
return string; |
} |
Following the basic rules, you don’t own the string returned by stringWithFormat:
, so you can safely return the string from the method.
By way of contrast, the following implementation is wrong:
- (NSString *)fullName { |
NSString *string = [[NSString alloc] initWithFormat:@"%@ %@", |
self.firstName, self.lastName]; |
return string; |
} |
更多推荐
potential leak of an object allocated and stored into ...
发布评论