(^. ^)메모리 해달라고 객체를 해제 할 때 감소
예를 맞아 "안녕 내 영어 다시 죄송 사람처럼 내 편집을 수정하면 나는이 감사하겠습니다 좋지 않다". 하지만 : 처음으로 만들기 버튼을 클릭하면 alloc이있는 새로운 View Controller가 생성되고 자동으로 count +1이 유지되고 kill 버튼을 누르면 -1이 유지되고 Equals가 0이되면 View Controller는 이 제거되었다는 것을 의미합니다. 내가 그렇게 코드를 수정 메모리을 형성 :
- (IBAction)create:(id)sender{
if(vc == nil){ //if is not nil this mean vc have some space of memory reference and vc is not created
//if == nil this mean vc does not have space of memory reference so create.
vc = [[VC alloc] initWithNibName:@"VC" bundle:[NSBundle mainBundle]];// retain count + 1
[_VW addSubview:vc.view];
}
및
- (IBAction)kill:(id)sender{
[vc.view removeFromSuperview]; //When view removeFromSuperview is called also dealloc is called of the vc view
[vc release];// retain count - 1 the curren count is equal 0 this mean vc does not have space of memory
vc = nil; // remove the reference of memory.
}
* 하지만 난 proyect의 프로필을 나는 버튼이 생성을 클릭하고 감소하지 않는 메모리를 죽일 때 단지 자랍니다 *
미안하지만 나는 초보자 게시자이기 때문에 이미지를 붙여 넣을 수는 없지만 라이브 바이트가 584,19kb 인 할당 초기화 프로필은 1 분 라이브 바이트가 1,08MB로 출시되지 않습니다.
내가 왜 만들고 올바르게 무료로 도와주세요. 한 번에 할당 1 및 할당 해제에 출시 - -
음, @의 RIP의 대답은 내가 [전] (제안 무엇 http://stackoverflow.com/questions/10150406/viewconroller-view-removefromsuperview-thread1-exc-bad-access-code-1-addres/10150623#입니다 comment13018709_10150623), 세부 코드 샘플이 포함되어 있습니다. :) – Kjuly
그리고 btw, 나는 당신이'[_VW addSubview : vc.view];'out of'if {}'를 넣어야한다고 생각합니다. – Kjuly