It will be a noob question, but i’m getting crazy with this. I’ve read a tons of topics but i think i am missing something main.
I`ve created new cocoa app project, did not change anything, just add next code to main.m
int main(int argc, char *argv[])
{
NSView *superview = [window contentView];
NSRect frame = NSMakeRect(10, 10, 200, 100);
NSButton *button = [[NSButton alloc] initWithFrame:frame];
[button setTitle:@"Click me!"];
[superview addSubview:button];
[button release];
return NSApplicationMain(argc, (const char **) argv);
}
During compiling xcode tells me that window undeclared. I understand that instead of window should be name of my NSWindow object, but i don`t understand which name has NSWindow which automatically created in MainMenu.xib file.
Please help, i`m almost ready to broke the wall with my head.
At that point no window has even been created yet. The code generated by Xcode gives you
windowin your projects application delegate, so add your code to-applicationDidFinishLaunching:inYourProjectAppDelegate.minstead.I recommend to start with some introductory material like Hillegass where such things should be covered in detail.