PDA

View Full Version : Syntax error before 'void'... Why?




macindev
Jul 6, 2009, 09:57 PM
Why am I getting this error message?

- (void)openWindow:(id)IBAction{
error: syntax error before 'void'
[self.window makeKeyAndOrderFront:self];
}

FYI: This is inside the implementation.

I am trying to make a method for opening a window by selecting a menu item, but I am barely starting to learn Objective-C and I only know HTML...



kainjow
Jul 6, 2009, 09:59 PM
Try:
- (IBAction)openWindow:(id)sender {
[[self window] makeKeyAndOrderFront:nil];
}

macindev
Jul 6, 2009, 10:04 PM
Try:
- (IBAction)openWindow:(id)sender {
[[self window] makeKeyAndOrderFront:nil];
}

Thanks, I tried that but am now getting a warning saying "'MyDocument' may not respond to '-window'". And, build fails with exit code 1 and says "duplicate symbol .objc_class_name_MyDocument"... :(


~ I do not know why this last part is happening, because I tried reverting the code back to a "working" state and I got the same error... strange... ~

macindev
Jul 7, 2009, 11:38 AM
I finally figured out what was wrong, I made another class for a nib file called "Browser" but the methods were duplicates of what was in "MyDocument" and that was keeping it from building.
:cool: