object-c释放内存的三种方式

1.

Person *p=[[Person alloc]init];
    [p eat];
    [Person name:@"wen" :@"male"];
    [p release];

2.

Person *p=[[[Person alloc]init]autorelease];
    [p eat];
    [Person name:@"wen" :@"male"];

3.

@autoreleasepool {
        Person *p=[[Person alloc]init];
        [p eat];
        [Person name:@"wen" :@"male"];
        // insert code here...
        NSLog(@"Hello, World!");
        
    }

 

 

posted on 2013-02-19 12:44  南瓜饼  阅读(391)  评论(0编辑  收藏  举报

导航