Naming conventions for BOOL Obj-C 2 properties?

前端 未结 5 1413

I have a readonly BOOL property. What is dominant naming pattern here?

Background: for plain old method declarations, the accepted pattern

- (BOOL)is         


        
5条回答
  •  一个人的身影
    2020-12-14 18:06

    I don't think it really matters, since KVO will look at both is and .

    Looking at the iPhone classes, the most common pattern I've seen is:

    @property(nonatomic, getter=isHidden) BOOL hidden;

    This let's you access the property in these ways:

    obj.hidden = YES; // (1)
    BOOL hidden = obj.hidden; // (2)
    BOOL hidden = [obj isHidden]; // (3)
    

    But not:

    BOOL hidden = obj.isHidden; // (4)
    

    CalStore does not follow that convention. You would be have to use line 4 instead of line 2.

提交回复
热议问题