문제

Some Cocoa and Cocoa Touch classes declare their delegate properties as assign rather than weak, which forces users of the class to nil out the property in dealloc

-(void)dealloc
{
    self.imageScrollView.delegate = nil;
    self.tableView.delegate = nil;
    self.tableView.dataSource = nil;
}

Which is very cumbersome.

Why would Apple do it this way?

도움이 되었습니까?

해결책

The reason why is that not all system classes have been compiled with ARC.

You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC.

See this page on developer.apple.com: Transitioning to ARC Release Notes

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top