admin管理员组文章数量:1530365
出现了标题的错误
查了一通,内存管理的问题
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; |
} |
本文标签: leakpotentialobjectstoredallocated
版权声明:本文标题:potential leak of an object allocated and stored into ... 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1725280926a1016488.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论