Re: NSButton question
Re: NSButton question
- Subject: Re: NSButton question
- From: Howard Griffith <email@hidden>
- Date: Thu, 08 Aug 2002 15:18:29 -0700
Lorenzo,
Just off hand, do you ever set TextField to begin with ?? If you don't
initially set the contents of the Textfield the first place your initial
button press sets it to "Hello Cocoa World!" if I am reading your included
source correctly.
You might want to try inserting this info the awakefromnib:
[myTextField setStringValue:@"Hello Cocoa World!"];
This will give it an initial value so the first time you press the button
the If statement in your changeText will work correctly.
Regards,
Howard Griffith
Mac Hobbyist
On 8/8/02 1:50 PM, "Lorenzo Thurman" <email@hidden> wrote:
>
--- On Thu 08/08, The MACed wrote:
>
From: The MACed [mailto: email@hidden]
>
To: email@hidden
>
Date: Thu, 08 Aug 2002 09:10:15 -0700
>
Subject: Re: NSButton question
>
>
> Mind posting some codes?
>
> Like your action method of the button.
>
>
>
Here's my action method:
>
- (IBAction)changeText:(id)sender
>
{
>
>
>
if([myTextField stringValue] == @"Hello Cocoa World!")
>
[myTextField setStringValue:@"Hello Aqua World!"];
>
else
>
[myTextField setStringValue:@"Hello Cocoa World!"];
>
>
>
}
>
>
>
Nothing special, just change the text field's label. Since my first message, I
>
tried using awakeFromNib like this:
>
>
>
@implementation MyController
>
>
>
- (IBAction)changeText:(id)sender
>
{
>
NSString *tmp;
>
>
>
tmp = currentText;
>
currentText = [myTextField stringValue];
>
[myTextField setStringValue:newText];
>
currentText = newText;
>
newText = tmp;
>
}
>
>
>
-(void)awakeFromNib{
>
>
>
currentText = @"Hello Cocoa World!";
>
newText = @"Hello Aqua World!";
>
>
>
}
>
@end
>
>
>
This works just fine, but I'd like to know why it does not work properly the
>
first time?
>
Thanks
>
>
>
>
------------------------------------------------
>
Join Excite! - http://www.excite.com
>
The most personalized portal on the Web!
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
>
--
Test
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.