当我必须释放一个对象时,我在某些情况下感到困惑?所以我想知道我们什么时候在目标C中释放对象。我可以在分配对象的地方使用自动释放自动释放的任何缺点吗?在哪里释放以下对象?
情况1:
SelectFrame *obj=[[SelectFrame alloc]initWithNibName:@"SelectFrame" bundle:nil];
[[self navigationController] pushViewController:obj animated:YES];
案例二:
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];