Re: Include an executable without hard coding the path
Re: Include an executable without hard coding the path
- Subject: Re: Include an executable without hard coding the path
- From: Rick Schmidt <email@hidden>
- Date: Sat, 18 Jul 2009 18:56:36 -0500
Thanks Greg, it took a long time but finally I got it to work. For
anyone else that finds this in the archives (I know I came along a lot
of posts that didn't have the solution) here is what worked for me.
NSBundle *bundle =[NSBundle mainBundle];
sequenceFileNS=[bundle pathForResource:@"sequencefile" ofType:@"txt"];
const char *sequenceFile2 = [sequenceFileNS UTF8String];
char *sequenceFile;
sequenceFile=const_cast< char*> (sequenceFile2);
Here I add to load a file file and pass it along as a char * to
another function. I couldn't find away to get a char * out of a
NSString object, only a const char * so I had to "cast away the
const-ness."
Rick
On Sat, Jul 18, 2009 at 10:30 AM, Greg Guerin<email@hidden> wrote:
>
>
>
> Subject: Re: Include an executable without hard coding the path
> From: Rick Schmidt <email@hidden>
> Date: Sat, 18 Jul 2009 01:24:01 -0500
> h=domainkey-signature:mime-version:received:in-reply-to:references
> :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding;
> bh=yikKCiSCXi3Luv2mjC7DKCCYPCcEoqdL4yUV4eZUPGs=;
> b=PsiUvpVk09hMNPHnadCULTCTjwKmeqwXWP9uBMb9SOHj3wHIvaQOK+KM2BTkUplNmA
> RnpnrUtipgG8GUZtYwpGbKk1RUaSsAsQWqJgdTeoyKS1g1EZdMQE8Tdly8S0rZtS0SLR
> bv3xWjo37z/0qhJLU8yPxNLyj9Zu5qCveiqHQ=
> h=mime-version:in-reply-to:references:from:date:message-id:subject:to
> :cc:content-type:content-transfer-encoding;
> b=YolDZ1HK9T84pJdOxkzuna89OBown+Cm5pSUp2m2wACUEnjPY18QLsZD3zibgse56Y
> PTVFKVu1XMYgWaiAoUlLCerfF3A2k/IoT+zX9B75UEnpuiaGBUevz2oF4Vf4STyDbWVg
> XVql7zTU9pA7HK3kvzjE8CYHkQQMxXOjuUGVQ=
>
>
>> Thanks Marcos I got that to work for the executable. Getting the path
>> to the sequence input file is another story. As far as I can see
>> NSBundle can only be assigned to an NSString. I have to get it as a
>> char* because I have to pass it into a c++ tool I didn't write. So
>> the the NSString has to go to a const char * and then a strcpy from
>> const char * to char *. It seems like it should be easier and its not
>> quite working yet.
>
> NSString has methods that return char* or that copy into a designated char
> buffer.
>
> Read the class reference doc for NSString. Xcode has this doc under its
> builtin Help system.
>
> For example: -length, -lengthOfBytesUsingEncoding:.
>
> Also: – getCString:maxLength:encoding:,
> – UTF8String
>
> Finally: -fileSystemRepresentation,
> -getFileSystemRepresentation:maxLength:
>
> I suspect getFileSystemRepresentation:maxLength is going to be the most
> useful for getting a pathname out of an NSString, but you should at least
> read the docs for the others so you know why.
>
> -- GG
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden