Application crashes if a property name starts with new

前端 未结 1 1865
深忆病人
深忆病人 2021-01-01 03:36

In my project I\'m using coredata. One of the entity has an attribute named newTotal, in its corresponding NSManagedObject class the property declaration is

相关标签:
1条回答
  • 2021-01-01 04:15

    I can see you are using ARC.

    In ARC memory is managed for you, but there are few things you can/have to do yourself. You cannot name property "newXxxx" because:

    https://developer.apple.com/library/mac/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

    You cannot give an accessor a name that begins with new. This in turn means that you can’t, for example, declare a property whose name begins with new unless you specify a different getter:

    // Won't work:

    @property NSString *newTitle;
    

    // Works:

    @property (getter=theNewTitle) NSString *newTitle;
    
    0 讨论(0)
提交回复
热议问题