• 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: NSRunAlertPanel-not working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRunAlertPanel-not working?


  • Subject: Re: NSRunAlertPanel-not working?
  • From: James McConnell <email@hidden>
  • Date: Mon, 16 Feb 2004 22:21:11 -0600

On 2/16/04 9:44 PM, "mmalcolm crawford" <email@hidden> wrote:
> Better still, if you're using 10.3, use bindings and implement
> validation methods for your model class.
>
> mmalc

Thanks for the tip! I've played around with bindings in Xcode, and I
honestly just can't seem to get a grip on them, at least not how they apply
to my project. I have a doc-based app that has basically one window with 7
text fields. Each text field represents a value in a model class (extends
NSObject). As a text field is filled and focus moves, the value of the text
field is copied to the model class. When the user saves, I simply archive
the object, then unarchive when they open it.

Honestly, I haven't seen enough documentation/examples to fully understand
how bindings work and how to use them in my application. I don't know if
I'm stupid and just can't get it, but it just isn't sinking in. So until I
know exactly how they work and how to use them, I'm doing things the "old"
way.

Right now, it's working the way I want it to, albeit probably sloppily, but
it's working. For me, that's a start.

BTW, I have the following code. If the field is empty, an alert box pops
up. But when OK is clicked, focus moves to the next field. I want the
focus to return to the field that was just validated until something is
entered. Here's my current code:

- (void)updateName:(NSNotification*)notification
{
if ([self validateTextField:name] == NO)
{
// I believe this whole statement is not what I want to happen
// How do I return focus to "name" if no value is entered and
// the user clicks "OK" on the alert panel?
[[name window] makeFirstResponder:name];
}

[recipe setName:[name stringValue]];
}

- (BOOL)validateTextField:(NSTextField*)textField
{
if ([[textField stringValue] isEqualToString:@""])
{
NSRunAlertPanel(@"Empty field", @"Please enter a value.",
@"OK", nil, nil);
return NO;
}
return YES;
}

Anyway, I'm still working on messing around with bindings in Xcode, but
until I can figure them out, this project is going to be written the hard
way. Maybe that alone will give me incentive to learn that!

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.

  • Follow-Ups:
    • Re: NSRunAlertPanel-not working?
      • From: Ryan Bates <email@hidden>
References: 
 >Re: NSRunAlertPanel-not working? (From: mmalcolm crawford <email@hidden>)

  • Prev by Date: Re: NSRunAlertPanel-not working?
  • Next by Date: Re: creating an NSImage from an NSMovie
  • Previous by thread: Re: NSRunAlertPanel-not working?
  • Next by thread: Re: NSRunAlertPanel-not working?
  • Index(es):
    • Date
    • Thread