[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception handling with NSURL

From: Richard Frith-Macdonald
Subject: Re: Exception handling with NSURL
Date: Thu, 06 Dec 2007 09:32:56 +0000
User-agent: GNUMail (Version 1.2.0)

On 2007-12-06 08:51:29 +0000 Philippe Roussel <address@hidden> wrote:

Hi all,

I'm trying to verify a string is a valid URL with the following :

- (void)controlTextDidChange:(NSNotification *)notification
      NSURL *storeUrl = [NSURL URLWithString:[url stringValue]];
      [ok setEnabled:(storeUrl != nil)];
      NSLog([localException name]);
      [ok setEnabled:NO];

When I enter an URL of the form http://user:address@hidden, an exception is
raised (see below) when starting to enter the password because NSURL is
expecting a numeric port (as in http://host:port). The thing is, the
exception isn't catched by NS_HANDLER (NSLog is never called) and the
application coredumps when I enter another caracter.

<NSException: 0x8357318> NAME:NSGenericException REASON:illegal
character in port part


Am I doing something wrong ?

My guess is that you are misinterpreting what's happening.

Probably the reason the NSLog() in the exception handler is not called is because the handler is not called because the exception is not ocurring in this piece of code. The exception message 'illegal character in port part' does not correspond to a URL for the form 'http://user:address@hidden' because such a URL has no port part, so it's presumably being raised because some otyher URL used elsewhere in the program has a port part containing an illegal character.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]