实际有效使用IBOutletColletion [英] Practical efficient usage of IBOutletColletion

查看:105
本文介绍了实际有效使用IBOutletColletion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何看待IBOutletCollection的实际用法?不幸的是,Apple文档在没有更广泛的使用概念的情况下提及了它。好吧,它与IB保持一对多的关系,但如何有效地访问和使用特定对象?使用TagName?如何确保对象的顺序?

How does look the practical usage of IBOutletCollection? Unfortunately Apple documentation mentions it briefly without giving an wider idea of usage. OK, it maintains one-to-many relation with IB, but how to access and use particular objects efficiently? With TagName? How to ensure the order of objects?

推荐答案

我最近使用它来轻松初始化标签网格。我在视图上有一个n×n标签矩阵,并分别引用每个标签(通过IBOutlet)以显示相关数据。但是,当视图首次加载时,我想控制所有标签中显示的默认文本。最初我想要一个破折号显示,但由于这是一个客户,我希望它很容易改变。根据客户端请求,视图内容会随着时间的推移而不断变化。

I've recently used this to easily initialize a grid of labels. I have a n by n matrix of labels on a view, and reference each one individually (via an IBOutlet) in order to display relevant data. However when the view first loads I wanted to control the default text that displayed in all the labels. Initially i wanted a dash to display, but since this is for a client I wanted it to be easy to change. The view contents have and continue to change over time, per client requests.

我创建了一个IBOutletCollection并在4中完成了相同的结果,而不是编写N行代码。 @property,@synthesize和for循环)。 YMMV,但我发现它在这种情况下非常有用。

Instead of writing N line of code, I created an IBOutletCollection and accomplished the same results in 4 (@property, @synthesize, and for loop). YMMV but I found it very useful in this situation.

这篇关于实际有效使用IBOutletColletion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆