开发者

Should I autorelease before return form -(NSString*)description?

Today i was overwriting -(NSString*)description method and i wondered if need to autorelease this string before returning it.

-(NSString*)description {
    NSMutableString *response = [[NSMutableString alloc] init];
    // perform appe开发者_JAVA技巧nds
    return [response autorelease];
}


Yes, as per ownership rule your function must not delegate the ownership of the returned string to the caller.


Yes. Any method whose name does not begin with alloc, new, copy, or mutableCopy should not return a retained object. See Memory Managment Rules

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜