1

I'd like to override the isDeleted property in NSManagedObject since it isn't being used in my application, and when it's accidentally been used in the past, subtle bugs were introduced. With that goal in mind, I was thinking of doing something like the following, and simply having all my NSManagedObject types inherit from this parent. Is this an optimal approach for what I'm looking to do?

@interface CustomManagedObject : NSManagedObject
@property (nonatomic, getter=isDeleted, readonly) BOOL deleted;
@end

@implementation CustomManagedObject

- (BOOL)isDeleted
{
    NSAssert(FALSE, @"Did you mean isDeleted, because that is not allowed...!");
}

// ....

@end
JaredH
  • 2,338
  • 1
  • 30
  • 40

1 Answers1

3

I think the following is more elegant to have:

@interface CustomManagedObject : NSManagedObject
@property (nonatomic, getter=isDeleted, readonly) BOOL deleted __attribute__((unavailable));
@end

Or

@interface CustomManagedObject : NSManagedObject
@property (nonatomic, getter=isDeleted, readonly) BOOL deleted __attribute__((deprecated));
@end

Give them a try.

Yuchen
  • 30,852
  • 26
  • 164
  • 234
  • Interesting. Thank you! For anyone reading this, more info on `__attribute__` here: http://nshipster.com/__attribute__/ – JaredH Jan 22 '15 at 02:44