objective C underscore property vs self
        Posted  
        
            by 
                user1216838
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1216838
        
        
        
        Published on 2012-12-08T10:57:24Z
        Indexed on 
            2012/12/08
            11:05 UTC
        
        
        Read the original article
        Hit count: 248
        
objective-c
I'm was playing around with the standard sample split view that gets created when you select a split view application in Xcode, and after adding a few fields i needed to add a few fields to display them in the detail view.
and something interesting happend in the original sample, the master view sets a "detailItem" property in the detail view and the detail view displays it.
- (void)setDetailItem:(id) newDetailItem
{
if (_detailItem != newDetailItem) {
    _detailItem = newDetailItem;
    // Update the view.
    [self configureView];
}
i understand what that does and all, so while i was playing around with it. i thought it would be the same if instead of _detailItem i used self.detailItem, since it's a property of the class.
however, when i used
self.detailItem != newDetailItem
i actually got stuck in a loop where this method is constantly called and i cant do anything else in the simulator.
my question is, whats the actual difference between the underscore variables(ivar?) and the properties? i read some posts here it seems to be just some objective C convention, but it actually made some difference.
© Stack Overflow or respective owner