开发者

An IBOulet for an NSArray size in a Non-Controller Class

开发者 https://www.devze.com 2022-12-11 09:02 出处:网络
I have a class along the lines of: @interface Foo : NSObject { NSMu开发者_如何学编程tableArray *bar;

I have a class along the lines of:

@interface Foo : NSObject {
    NSMu开发者_如何学编程tableArray *bar;
}

Foo isn't a controller -- it's responsible for some other logic that I want encapsulated.

I'd like to have a label display the size of bar. If it was a value in a controller, I could simply make it an IBOutlet, connect it in IB, and everything would just work.

Can I do that with bar above?


If you're using that class to encapsulate certain functionality, don't use it to update the UI too. Rather have an instance of class Foo in your view controller and let your view controller update the label's value with the value of bar's size. You should make bar available via an accessor

0

精彩评论

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