Re: Creating NSURL from Apple Event string
Re: Creating NSURL from Apple Event string
- Subject: Re: Creating NSURL from Apple Event string
- From: Matt Neuburg <email@hidden>
- Date: Sat, 14 Oct 2006 11:21:00 -0700
- Thread-topic: Creating NSURL from Apple Event string
On Tue, 10 Oct 2006 14:08:34 -0500, "a.d. jensen" <email@hidden>
said:
>I have this really annoying issue that keeps coming up over and over
>and I'm at my wits end. Hopefully I can get some help.
>
>I have a Cocoa application that receives a URL in a string in an
>Apple Event and opens a web view of the page. I have two different
>applications that are sending this Apple Event, one is a Carbon C++
>program, the other a Carbon Pascal app (written in FPC, compiled in
>xCode.)
>
>The C++ program seems to send the string fine, and the Cocoa app
>opens the page fine.
>
>The Pascal program, on the other hand, just seems to send over bad
>strings (which I've converted from Pascal Str255 to zero-terminated C
>strings). They SEEM to be valid, but when I run this:
>
>NSURL *myURL = [NSURL URLWithString: urlString];
>
>I get a nil myURL. Documentation says it will be nil if "urlString"
>is invalid. In the debugger, it sure LOOKS valid, and if I replace
>that line with:
>
>NSURL *myURL = [NSURL URLWithString: @"http://www.apple.com"];
>
>it works fine.
>
>How do I figure out what's wrong with "http://www.apple.com" in a
>NSString, that isn't wrong when I use @"http://www.apple.com" directly?
You say you're getting this value originally from an Apple event, but you
don't say what Apple event it is. It might be crucial to know that. I ran
into a situation recently where I was getting back a UTF-16 bytestring and
the receiving program (parallel to your Pascal situation?) didn't know what
to do with that. Like your example, it *looked* right, but that was because
I couldn't see the null characters between the visible characters. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden