开发者

Method return values

开发者 https://www.devze.com 2023-03-16 19:13 出处:网络
Objective C docs from apple says For the object-oriented constructs of Objective-C, such as method return

Objective C docs from apple says

For the object-oriented constructs of Objective-C, such as method return values, id replaces int as the default data type. (For strictly C constructs, such as function return values, int remains the default type.)

I thought the return type and hence value is something predefined in method signature. So could you give me some example o开发者_JS百科n what the doc refers to?


That line simply means that a method written as such, would, by default, return id:

- init { ... }

or

+ array { ... }

versus

- (id)init { ... }

In addition, a method written without explicit parameter types will take in id objects.

- initWithObject:object { ... }

is the same as

- (id)initWithObject:(id)object { ... }
0

精彩评论

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