开发者

Where should I set default variable values in ObjectiveC class

开发者 https://www.devze.com 2023-04-05 03:13 出处:网络
I can\'t set default values in the header file, so where should they be set? In the class\'s designate开发者_开发百科d initialiser?Yep, if you need specific values, use the init like methods.

I can't set default values in the header file, so where should they be set? In the class's designate开发者_开发百科d initialiser?


Yep, if you need specific values, use the init like methods. This is the recommended way.

The designated initializer is the method in each class that guarantees inherited instance variables are initialized (by sending a message to super to perform an inherited method). It’s also the method that does most of the work, and the one that other initialization methods in the same class invoke. It’s a Cocoa convention that the designated initializer is always the method that allows the most freedom to determine the character of a new instance (usually this is the one with the most parameters, but not always).

0

精彩评论

暂无评论...
验证码 换一张
取 消