• 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: Delegate methods not working...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delegate methods not working...


  • Subject: Re: Delegate methods not working...
  • From: Hiro Fujimoto <email@hidden>
  • Date: Sat, 6 Mar 2004 14:18:50 +0900

Hi, James,

Try this:

if([[control stringValue] length] == 0){
NSRunAlert(...);
}


--


On 2004/03/06, at 12:00, James McConnell wrote:

Hey all, it's me again ;-). I have a doc based app with several text
fields. In IB, I've connected each NSTextField to File's Owner
(MyDocument), and set MyDocument as each fields delegate. In MyDocument.m,
I've implemented the following method which checks the value of the text
field. Everything compiles fine, but when I change text fields without
entering an value, I do not get the NSAlertPanel like I expect. Can anyone
see anything wrong? I've searched the list archives as well as
cocoa.mamasam.com, and found nothing helpful.

<start code>

- (BOOL)control:(NSControl*)control
textShouldEndEditing:(NSText*)fieldEditor
{
if ([[control stringValue] isEqualToString:@""])
{
NSRunAlertPanel(@"Empty field", @"Please enter a value.", @"OK",
nil, nil);
return NO;
}

[recipeController updateRecipe]; // simply updates a model object
return YES;
}

<end code>

Now, this is what was suggested by Ryan Bates in an earlier conversation
(thanks again, Ryan!), but it's not working. I had this working with
notifications, but everytime a notification was fired for one text field, it
would fire every notification for all the text fields. Besides, I need
notifications to do something else, and would like to get this to work so I
can keep notifications for their other job. Thanks again for all the help.

James
_______________________________________________
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.


------------------------------------------------------------------------ ---------
hiro FUJIMOTO - developer in Japan.
_______________________________________________
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.


  • Prev by Date: Re: drag and drop: NSView vs. NSImageView
  • Next by Date: Re: Delegate methods not working...
  • Previous by thread: Re: Delegate methods not working...
  • Next by thread: Re: Delegate methods not working...
  • Index(es):
    • Date
    • Thread