1

The problem is I need to use properties in NSManagedObject as scalar properties except single one NSDate property.

Can I do this without subclassing? can I just replace

@property (nonatomic) NSTimeInterval birthDate;

with

@property (nonatomic, retain) NSDate * birthDate; ?

Or maybe there is another way to achieve this? Actually I just need one more additional state for my date property to check if nil (if some date actually set). Can I check it somehow with NSTimeInterval?

Thanks!

iiFreeman
  • 5,165
  • 2
  • 29
  • 42

1 Answers1

2

Yes, you can just replace the Xcode generated property declaration. The actual accessor methods are created at runtime and (magically) do the right thing. One problem is of course that Xcode will overwrite the declaration if you re-create the class files.

If you use "mogenerator" then you will get accessors for both the scalar NSTimeInterval and the NSDate, as nicely explained here: What features does mogenerator provide?.

Alternatively, you could define a "default value" in the Core Data model inspector which is unlikely to be a real birth date.

Community
  • 1
  • 1
Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382