I put UIButton on UIVIewController by StoryBoard.
in xxxVIewController.h
@interface xxxViewController : UIViewController{
IBOutlet UIButton *But;
}
@property (retain, nonatomic) IBOutlet UIButton *But;
I would like to access “*But” from another class to change setimage of UIButton.
I think if I can get the instance of UIViewController,it is solved…..
Does anyone give me the hint
thanks He-Was ,Jasper Blues I added comments .
One is xxxViewController which doesn’t contain navigation controller.
it contains only four buttons.
The other is TimerClass (NSObject)
which manage the time of application.
TimerClass class has timer.
What I want to do is
changing the button color on xxxViewController every a few seconds from TimerClass.
I can access TimerClass method easily.
because xxxViewController has TimerClass instance.
But xxxViewController was made by automatic,so I am not sure how to get xxxViewController instance from TimerClass.
I would setup
xxxVIewControlleras a delegate forTimerClassand when you create yourTimerClassinstance, set the delegate toself.ie:
Then, when it is time to update the button, you should call a delegate function in
xxxVIewControllerand have it update its own button:Read up on protocols if you aren’t familiar and you will see a good way to implement this in a more general fashion.