當我必須釋放一個對象時,我在某些情況下感到困惑嗎?所以我想知道什麼時候在Objective C中釋放對象。我可以使用autorelease在哪裏分配對象autorelease的任何缺點?在哪裏發佈以下對象?目標釋放對象C
案例1:
SelectFrame *obj=[[SelectFrame alloc]initWithNibName:@"SelectFrame" bundle:nil];
[[self navigationController] pushViewController:obj animated:YES];
案例2:
UIView *barView=[[UIView alloc]initWithFrame:CGRectMake(0, 500, 200,50)];
barView.backgroundColor=[UIColor redColor];
[self.view addSubview:barView];
案例3:
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:@"https://xxxxxxxxxxxxxxxxx"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
謝謝你回答,我還有一個問題,我使用JSON和幾個對象顯示內存泄漏JSON SDK .m文件?當我啓用ARC,然後這些文件顯示我錯誤。如何在ARC上使用JSON sdk – QueueOverFlow
我對使用的代碼瞭解不多。但你可以谷歌這樣的事情。 http://stackoverflow.com/questions/8701780/using-non-arc-code-in-an-arc-enabled-project-adding-facebook – mayuur