0

I have the following code. self.settingsObject is always nil? What is the issue?

.h file
@interface RoomConfigurationViewController : ATBaseViewController {

}
  @property (nonatomic, strong) AttendanceSettings *settingsObject;
@end


.m file
@synthesize settingsObject = _settingsObject;


NSData *settingsData = [[NSUserDefaults standardUserDefaults]     objectForKey:kUserDefaultsSettingsObject];
self.settingsObject = [NSKeyedUnarchiver unarchiveObjectWithData:settingsData];
jdog
  • 10,351
  • 29
  • 90
  • 165
  • 3
    Did you try NSLogging `settingsData` and then `[NSKeyedUnarchiver unarchiveObjectWithData:settingsData]`..? – Ravi Sep 20 '12 at 17:30
  • Yes, I have debugged and settingsData is there. In another part of the app, a VC, the data gets archived. – jdog Sep 20 '12 at 19:21
  • Well, you should give us more code to see what's wrong. You said `settingsData` is allocated and existing, how about NSLogging `[NSKeyedUnarchiver unarchiveObjectWithData:settingsData]`? Also have you tried doing a formal `[settingsObject = [[AttendanceSettings alloc] init];` AND THEN `self.settingsObject = [NSKeyedUnarchiver unarchiveObjectWithData:settingsData];`? – Ravi Sep 20 '12 at 21:11
  • Ravi, no I have not. Ok if I use an @interface in the .m file and do property (nonatomic, strong) Thing *settingsObject in there it fails. But, if I move the property into the .h (interface) file it works. – jdog Sep 21 '12 at 00:43

0 Answers0