• 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: Using control:didFailToFormatString:errorDescription:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using control:didFailToFormatString:errorDescription:


  • Subject: Re: Using control:didFailToFormatString:errorDescription:
  • From: Rohan Lloyd <email@hidden>
  • Date: Tue, 9 Sep 2008 12:10:10 +1000


On 9 Sep 2008, at 12:48 AM, Matt Neuburg wrote:

On Mon, 8 Sep 2008 11:23:30 +1000, Rohan Lloyd <cocoa- email@hidden> said:
I don't like the vague "Format Error" and want to display my own
message, so I've written my own
control:didFailToFormatString:errorDescription: method (In my
NSWindowController subclass), and set the text field delegate to point
at it.


- (BOOL)control: (NSControl*)control didFailToFormatString:
(NSString*)str errorDescription: (NSString*)errDescription
{
NSError *error = [NSError errorWithDomain: NSCocoaErrorDomain
code: NSFormattingError userInfo: nil]; // Add custom description later
[control presentError: error modalForWindow: [self window]
delegate: nil
didPresentSelector: nil
contextInfo: nil];


   return YES;
}

First thing's first. Documentation says return value should be:

Return Value
YES if the value in the string parameter should be accepted as is; otherwise,
NO if the value in the parameter should be rejected.

If you don't like the string, you should not be returning YES. m.

You're right I should have read that part of the documentation. However, I had tried returning NO, and it didn't really help.


If I return NO, not only do I get my error displayed, but the standard error dialog is also shown. Which suggests that the return value is overloaded with a "I have handled this error" meaning. This is backed up by the following page that I read:

  ://initgraf.blogspot.com/2007/11/customizing-errors-generated-by.html

Where it says, "You need to return YES, or else you'll get both your custom error and the standard error."


-- Rohan Lloyd


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Using control:didFailToFormatString:errorDescription: (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Finding out in code how much memory my application uses
  • Next by Date: While we're on the subject of DMG's for software distribution...
  • Previous by thread: Re: Using control:didFailToFormatString:errorDescription:
  • Next by thread: Re: Using control:didFailToFormatString:errorDescription:
  • Index(es):
    • Date
    • Thread