Re: Creating NSURL from Apple Event string
Re: Creating NSURL from Apple Event string
- Subject: Re: Creating NSURL from Apple Event string
- From: "a.d. jensen" <email@hidden>
- Date: Tue, 10 Oct 2006 14:29:29 -0500
On Oct 10, 2006, at 2:21 PM, Shawn Erickson wrote:
Can you outline how you construct the NSString you feed into
URLWithString:? Also how you convert from a Str255 to a C string?
Sure, from the Cocoa end of things:
NSAppleEventDescriptor *directObjectDescriptor = [event
paramDescriptorForKeyword:keyDirectObject];
NSAppleEventDescriptor *myAEDescriptor = [directObjectDescriptor
descriptorAtIndex:1];
NSString *urlString = [myAEDescriptor stringValue];
and in the Pascal app:
procedure ConvertPStringToCString(var returnValue: Str255);
var
count: integer;
utilStr: Str255;
begin
utilStr:= returnValue;
for count:= 0 to 255
do returnValue[count]:= chr(0);
for count:= 1 to length(utilStr)
do returnValue[count - 1]:= utilStr[count];
returnValue[length(utilStr)]:= chr(0);
end; { ConvertPStringToCString }
and in the create Apple Event function:
string1:= 'http://www.apple.com';
ConvertPStringToCString(string1);
iErr:= AECreateDesc(typeCString, @string1, 256, docDesc);
If I look at string1 in the debugger, it is indeed (effectively) an
array of char, first bit being the URL, last bit all zeros. I'm
operating on the assumption that data is data, I'm just dealing with
pointers here, so it doesn't matter how it's being stored
internally. Maybe that's my problem.
dale
--
email@hidden http://kandsmil.blogspot.com
Only a fool turns away from an angel,
Vision in white steps through the door,
Holds out her hand, I say 'No I'm not ready'
I open my eyes and let the dream fade away.
-- echolyn, "on any given nite"
_______________________________________________
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