开发者

Does ARC mean I should declare static types rather than id?

The ARC document is publicly available on the LLVM site, so NDA is not an issue here.

I find that in getting my code ready for ARC, I am using (NSObject*) in a lot of situations where I would have formerly used (id).

For example, if I were writing an initWithParent: method, it might be

-(id) initW开发者_高级运维ithParent: (NSObject*) parent;

where I would formerly have written

-(id) initWithParent: (id) parent;

My question is -- does this practice make sense?


I believe that will work for most cases, at least if your object derives from NSObject (which not quite everything does). Here's an interesting blog post on the subject (independent from ARC).


I'm by no means any expert but it seems like it might run into trouble if the message passes something that is not an object (int, struct, etc…).

Other than that, it's an interesting way of getting around things.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜