Hello,
I'm trying to change the enabled property of an UIBarButtonItem after doing some stuff in an NSThread. After pressing the button I set the enabled to NO then perform the threaded part and at the end I try to re enable the button. Fairly basic.
Somehow this fails, however I'm able to change any other property of the the UIBarButtonItem correctly (for ex. title).
What am I doing wrong here?
Many thanks in advance!
@interface myViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
IBOutlet UIBarButtonItem *myButton;
}
@property (nonatomic, retain) IBOutlet UIBarButtonItem *myButton;
- (IBAction)mysub:(id)sender;
@end
@implementation myViewController
@synthesize myButton;
- (IBAction)mysub:(id)sender {
[myButton setEnabled:NO];
[NSThread detachNewThreadSelector:@selector(mysub_threaded) toTarget:self withObject:nil];
}
- (void) mysub_threaded {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
… do threaded stuff
[myButton performSelectorInBackground: @ selector(setEnabled :) withObject: [NSNumber numberWithBool:YES]];
[pool drain];
}