Created
September 25, 2008 18:46
-
-
Save nickjs/12893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation LEProfilesController : CPObject | |
{ | |
CPDictionary profiles; | |
CPArray observers; | |
} | |
+ (LEProfilesController)defaultController | |
{ | |
if(!LEDefaultProfilesController) | |
LEDefaultProfilesController = [[LEProfilesController alloc] init]; | |
if(!LEDefaultProfilesController.profiles) | |
LEDefaultProfilesController.profiles = [CPDictionary dictionary]; | |
return LEDefaultProfilesController; | |
} | |
- (void)addProfile:(LEProfile)aProfile | |
{ | |
[profiles setObject:aProfile forKey:aProfile.id]; | |
for(var i=0;i<observers.length;i++){ | |
[observers[i] setCollection:[[self collection] copy]]; | |
} | |
} | |
- (CPDictionary)collection | |
{ | |
return profiles; | |
} | |
- (void)observeCollection:(id)anObject | |
{ | |
if(!observers){ | |
observers = [CPArray array]; | |
} | |
[observers addObject:anObject]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment