方法名称遵循一组规则 -阅读此链接;)
基本上,以alloc、new、copy或开头的名称mutableCopy需要您调用release(或autorelease)。
返回对象的任何其他方法都将返回自动释放的对象。
例如 :
// You need to release these
NSString *myString = [[NSString alloc] init];
NSString *nextString = [myString copy];
UIbutton *button = [[UIButton alloc] initWithType:UIButtonTypeCustom];
// You don't need to release these
NSString *thirdString = [NSString stringWithString:@"Hello"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
Run Code Online (Sandbox Code Playgroud)
希望有帮助!
| 归档时间: |
|
| 查看次数: |
4431 次 |
| 最近记录: |