• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: make connections without InterfaceBuilder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make connections without InterfaceBuilder


  • Subject: Re: make connections without InterfaceBuilder
  • From: Ian Jackson <email@hidden>
  • Date: Tue, 9 Feb 2010 20:33:11 +1300

Can I just clarify, are you specifically trying to do this in code because you want to, or because you don't know how to make the connections in Interface Builder?

In interface builder control drag from the control to the appDelegate for the action, and from the AppDelegate to the control for the outlet.

Sorry if you already know this.

Ian.

On 9/02/2010, at 5:03 PM, Jonathan Chacón wrote:

> 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

 _______________________________________________
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

References: 
 >make connections without InterfaceBuilder (From: "Jonathan Chacón" <email@hidden>)
 >Re: make connections without InterfaceBuilder (From: Ken Thomases <email@hidden>)
 >Re: make connections without InterfaceBuilder (From: Jonathan Chacón <email@hidden>)

  • Prev by Date: Re: make connections without InterfaceBuilder
  • Next by Date: Re: make connections without InterfaceBuilder
  • Previous by thread: Re: make connections without InterfaceBuilder
  • Next by thread: Re: make connections without InterfaceBuilder
  • Index(es):
    • Date
    • Thread