Semantic Issue: Property's synthesized getter follows Cocoa naming convention for returning 'owned' objects

前端 未结 10 1242
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 06:54

I\'m currently using the iOS 5 SDK trying to develop my app. I\'m trying to make an NSString a property, and then to synthesize it in the .m file (I have done this before wi

10条回答
  •  悲哀的现实
    2020-12-07 07:27

    Besides the issue that you should/can't use "new" in front of you property names, let say one more thing: Try to avoid "new" in front of names in general. "New" is dependent on time. Currently it is new for you, but some time later you maybe want to implement something new again. So using "new" in names is always bad. Try to think this way: In the programming world, "new" is always creating something: a new instance of something.

    In your case when you want to assign a different title then the current name your property titleReplacement.

    One more thing: Try to name functions and methods with the verb first, like setSomething or getSomething. But in properties try to name the object first, like heightMinimum, heightMaximum, etc. -> when you use your inspector when you are coding, you always looking for objects. Try it out. ;-)

提交回复
热议问题