Let’s say I have a custom object, like a NSButtonCell, that I want to save to a file, but without its title. There is a way to do it in ASOC, i.e. to send a myButton’s setTitle_(“”) before saving it. The title is saved as an empty string.
Is there a way to “inhibit” the coding of the title (or any other property) in the ObjC implementation? That seems strange, because the usual need to override a method is to ADD something.
(void)encodeWithCoder:(NSCoder *)encoder {
[super encodeWithCoder:encoder]; ← the inherited method encodes the title. How to prevent this?
Note: this feature is not essential, but I was just wondering.
I think the only way to actually prevent it from being encoded would be to re-write the encodeWithCoder method to override the super’s implementation of it – and then don’t call the super’s method. Of course, you could only do that if you had Apple’s code for that implementation, which you don’t.
I think you could make it look like you didn’t encode it by adding “self.title = nil” in the initWithCoder method.