views:

44

answers:

2

Hi!

I made a toolbar with two buttons on it. I then created two outlets in my class controller. Then I hooked the the controller to the buttons and selected the outlets.

Finally I rewritten the class files (that added:

IBOutlet id next;
IBOutlet id previous;

to my .h file).

So now, everything looks okay. But then I try somewhere in the code to change the state of one of my button like this:

next.enabled = YES;

I tried with self. too but unfortunately I receive this error message: error: request for member 'enabled' in something not a structure or union

Do you have any idea of what's happening there?

And yes I have:

#import <UIKit/UIKit.h>

:)

Using:

[next setEnabled:YES];

gives me no error but still doesn't work...

And finally, for documenting purposes here's the whole method:

- (void)viewDidLoad {
    [super viewDidLoad];

     if (!self.currentLevel) {
          self.currentLevel = @"1";
     }

     NSArray *etape = [self.etapes objectForKey:self.currentLevel];
     if ([etape count] > 0) {
          self.navigationItem.title = [etape objectAtIndex:1];
          if ([etape count] > 1) {
               [next setEnabled:YES];
          }

     } else {
          self.navigationItem.title = @"Aucune étape";
     }
}

When I do:

NSLog(@"%@", [next class]);

It returns (null) ... I guess it is supposed to be UIBarButtonItem...

It seems that it is impossible to play with any outlets even if I don't receive any errors while playing with them...

+1  A: 

That should be:

IBOutlet UIButton * next;
IBOutlet UIButton * previous;
rcw3
That changed absolutely nothing... Sill does not work :/ Thanks anyways!
Tom
A: 

I'm not sure about the iphone SDK because I don't use it, but you enable/disable toolbar items using the following method. I usually use the button's label to identify which button I target.

-(BOOL)validateToolbarItem:(NSToolbarItem*)theItem {
    BOOL shouldEnable = YES;
    NSString* itemLabel = [theItem label];
    if ([itemLabel isEqualToString:@"next"]) {
        shouldEnable = NO;
    }
    return shouldEnable;
}
regulus6633