An IBOulet for an NSArray size in a Non-Controller Class
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
精彩评论