Skip navigation.
 
mlregisterDefaults error and NSCoding protocol
FROM : John Clayton
DATE : Thu Nov 27 20:56:05 2008

Hi,

Question about registering defaults - I'd assumed the following would 
be valid, assuming that GuideSettings implements the NSCoding protocol 
- but my app doesn't like this and throws a bad access exception in 
CFRetain when I run this code:

The bit that falls over is the registerDefaults: call - the stack 
track being:

#0    0x96fc52d4 in CFRetain
#1    0x96f94a54 in CFDictionarySetValue
#2    0x97029dd3 in -[CFXPreferencesSource setValue:forKey:]
#3    0x9702acce in __CFXPreferencesSetValuesInSource
#4    0x9702e30d in _CFXPreferencesRegisterDefaultValues
#5    0x92b90a98 in -[NSUserDefaults(NSUserDefaults) registerDefaults:]
#6    0x000ae543 in -[DataModelDefaults init] at DataModelDefaults.m:90


- (id) init {
   self = [super init];
   
   _defs = [NSUserDefaults standardUserDefaults];
   NSArray* defaultGuides = [DataModelDefaults defaultGuideSettings];
   NSDictionary* defs = [NSDictionary dictionaryWithObjectsAndKeys:
                         defaultGuides, kGuideSettings,
                         [NSNumber numberWithFloat:2], kEffectDefaultsDurationSeconds,
                         0];
   
   // this goes BOOOOOM
   [_defs registerDefaults:defs];

   return self;
}

+ (NSArray *) defaultGuideSettings {
   // simply return a list of the guide objects we want to have as 
defaults
   NSMutableArray* array = [[NSMutableArray new] autorelease];
   [array addObject:[GuideSetting guideSettingNamed:@"Standard" width:
640 height:480]];
   [array addObject:[GuideSetting guideSettingNamed:@"Standard" width:
800 height:600]];
   [array addObject:[GuideSetting guideSettingNamed:@"YouTube" width:848 
height:480]];
   return array;
}

Am I forgetting something? I thought as long as my object could encode/
decode itself, all would be OK - anyone know what I'm doing wrong?

Thanks
--
John Clayton
Skype: johncclayton

Related mailsAuthorDate
mlregisterDefaults error and NSCoding protocol John Clayton Nov 27, 20:56
mlRe: registerDefaults error and NSCoding protocol Bill Bumgarner Nov 27, 21:25