(iphone)从后台线程访问 UIView 的数据成员是否安全?
我知道你无法从后台视图更新 UIView。
但不确定当我仅访问 UIView 后代的自定义数据成员变量时该规则是否适用。
假设我在
@interface MyView : UIView
{
NSNumber* number;
}
@property (retain) NSNumber* number;
这里,从后台线程访问“number”变量是否违反了“后台线程没有 UIView 更新”规则?
谢谢
I know that you can't update UIView from background view.
But not sure if that rule applies when I'm only accessing custom data member variable of UIView descendants.
Suppose I have
@interface MyView : UIView
{
NSNumber* number;
}
@property (retain) NSNumber* number;
Here, does accessing the "number" variable from background thread violate the rule "no UIView update from background thread" ?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果子类属性被标记为原子(默认),则在后台线程中访问子类属性不会导致任何问题。您必须确保不调用任何导致绘图的 UIView 方法。
Accessing your subclasses properties in a background thread shouldn't cause any problems if they are marked as atomic (the default). You have to make sure that you don't call any UIView methods that cause drawing though.