开发者

iOS: Alternative to IBOutlet?

I've got a lot of really huge viewControllers. In fact there's a lot of useless code:

property for each view from InterfaceBuilder

synthesize

and release in dealloc

I'm thinking may be it is possible to have them all (all views that I need) in collection. But I won't have any IBOutlet in this case. how to connect the开发者_开发百科m with IB?

Can you help me? I really don't like when there's 3 places with so similar code=(


You could use an IBOutletCollection, but generally those should be reserved for when you are using very similar objects (e.g. several buttons whose state needs to change together). I would seriously reconsider trying to rewrite your code to use something that could potentially make your job harder down the road.

Honestly though, you shouldn't really worry about the lines of code you need for setting up and tearing down the view. You could just collapse those sections of code if you don't like looking at them. These are going to be standard for Obj-C graphical apps you write. Consider that if someone else needed to pick up work on your application where you left off, it would take longer for them to figure out the IBOutletCollections vs using separate IBOutlets for each piece of the UI.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜