Skip to content

Instantly share code, notes, and snippets.

@nickjs
Created September 25, 2008 18:46
Show Gist options
  • Save nickjs/12893 to your computer and use it in GitHub Desktop.
Save nickjs/12893 to your computer and use it in GitHub Desktop.
@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