1

In my coreData model I have defined an entity MyEnity with several attributes. Among them two attibutes :

mute : Boolean 
deleted : Boolean

I have a NSManagedObject class associated with MyEntity. In this class I have :

@NSManaged var mute: NSNumber
@NSManaged var deleted: NSNumber // compilation error

But the second line produces an error and can't be compiled. This is the error I get :

Property 'deleted' with type 'NSNumber' cannot override a property with type 'Bool'

I don't understand what is the issue and why I don't have the same issue for the mute attribute ?

ABakerSmith
  • 22,759
  • 9
  • 68
  • 78
Cherif
  • 5,223
  • 8
  • 33
  • 54
  • 1
    please try to change name.. instead of deleted you change it to delete 1 and try again. – Ashok Londhe May 11 '15 at 09:44
  • Please check in the CoreDataModel what the type of `deleted` is. Then please recreate the NSManagedObject Subclass via Editor Tab in the Menu – gutenmorgenuhu May 11 '15 at 09:45
  • The problem is the attribute name "deleted". I worked when I changed it. Thanks @Ashok – Cherif May 11 '15 at 09:50
  • 1
    @Cherif i think deleted may be the keyword in iOS. so my comment help you? – Ashok Londhe May 11 '15 at 09:52
  • I found it by my self... just before reading your comment. It was a matter of seconds. Put it as an answer and I will validate it ;) – Cherif May 11 '15 at 09:54
  • At least the Swift compiler notices the conflict now. In Objective-C, it went unnoticed and caused very strange effects, see http://stackoverflow.com/questions/16000242/core-data-nspredicate-predicatewithblock-and-predicatewithformat-in-parent-child for an example . – Martin R May 11 '15 at 09:55

1 Answers1

3

NSManagedObject has a property named deleted as shown here so using deleted variable name will override that property, in your case with inappropriate type (NSNumber instead of Bool) and thats cause a compile time error

Zell B.
  • 10,266
  • 3
  • 40
  • 49