Show
Ignore:
Timestamp:
16-04-2008 18:01:32 (5 years ago)
Author:
jppavao
Message:

Improved KVO registration to members of collections in some places in order to avoid using loops.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lilypad/Sources/LPEditContactController.m

    r251 r270  
    140140- (void)p_startObservingEntries:(NSArray *)contactEntries 
    141141{ 
    142         NSEnumerator *entriesEnumerator = [contactEntries objectEnumerator]; 
    143         LPContactEntry *entry; 
    144          
    145         while (entry = [entriesEnumerator nextObject]) { 
    146                 [entry addObserver:self 
    147                                 forKeyPath:@"allResourcesDescription" 
    148                                    options:0 
    149                                    context:NULL]; 
    150         } 
     142        NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [contactEntries count])]; 
     143        [contactEntries addObserver:self toObjectsAtIndexes:indexSet forKeyPath:@"allResourcesDescription" options:0 context:NULL]; 
    151144} 
    152145 
    153146- (void)p_stopObservingEntries:(NSArray *)contactEntries 
    154147{ 
    155         NSEnumerator *entriesEnumerator = [contactEntries objectEnumerator]; 
    156         LPContactEntry *entry; 
    157          
    158         while (entry = [entriesEnumerator nextObject]) { 
    159                 [entry removeObserver:self forKeyPath:@"allResourcesDescription"]; 
    160         } 
     148        NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [contactEntries count])]; 
     149        [contactEntries removeObserver:self fromObjectsAtIndexes:indexSet forKeyPath:@"allResourcesDescription"]; 
    161150} 
    162151