Re: make connections without InterfaceBuilder
Re: make connections without InterfaceBuilder
- Subject: Re: make connections without InterfaceBuilder
- From: Jonathan Chacón <email@hidden>
- Date: Tue, 9 Feb 2010 05:03:19 +0100
Hello,
I did this:
I created a new Cocoa project (prueba)
I opened mainMenu.xib in interface builder
I added a pushbutton
I edited the pushbutton:
x = 10
y = 300
title = "boton"
name = boton
I saved it and I close interface builder
I edited pruebaAppdelegate.h and pruebaAppDelegate.m
after it, I press build and run. The app runs but I click the button and nothing happends.
where is the error?
pruebaAppDelegate.h
#import <Cocoa/Cocoa.h>
@interface pruebasAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet NSButton *boton;
}
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet NSButton *boton;
- (IBAction)botonClick:(id)sender;
@end
pruebaAppDelegate.m
#import "pruebasAppDelegate.h"
@implementation pruebasAppDelegate
@synthesize window;
@synthesize boton;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}
- (void)awakeFromNib:(id)sender {
[boton setTarget:self];
[boton setAction:@selector(botonClick:)];
}
- (IBAction)botonClick:(id)sender {
[boton setTitle:@"pulsado"];
[window setTitle:@"Has pulsado el botón"];
}
@end
thanks and regards
Jonathan Chacón
El 08/02/2010, a las 23:03, Ken Thomases escribió:
> On Feb 8, 2010, at 9:28 AM, Jonathan Chacón wrote:
>
>> How can I do this in xCode? is there any way to do this from source?
>>
>> I read about setTarget and setAction but I don't know where can I include these sentences.
>
> Probably the best place would be in the -awakeFromNib method of the object which will be the NIB's owner. For the MainMenu NIB, the File's Owner is the application object, which you don't ordinarily subclass (although that's not a hard-and-fast rule). So, it might be better in the app delegate's -awakeFromNib.
>
> Cheers,
> Ken
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden