• 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: NSString to char[]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString to char[]


  • Subject: Re: NSString to char[]
  • From: Jerry Brace <email@hidden>
  • Date: Sun, 24 Jul 2005 15:20:00 -0230

Hey Guys,

I found a solution that works - let me know what you think:

NSMutableString * path = [thisBundle pathForResource:@"wakein" ofType:@""];

    unsigned int lengthOfMessage = [path length];
    char sysctlPath[lengthOfMessage + 1];
    strcpy(sysctlPath, [path UTF8String]);

Cheers,
Jerry

On 24-Jul-05, at 3:11 PM, John Stiles wrote:

Maybe you should take a look at the return type of - fileSystemRepresentation.


On Jul 24, 2005, at 10:20 AM, Jerry Brace wrote:


I get the same error using fileSystemRepresentation - "error: invalid identifier"

NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];
NSString * path = [thisBundle pathForResource:@"wakein" ofType:@""];


AuthorizationRights rights;
AuthorizationRights *authorizedRights;
AuthorizationFlags flags;
AuthorizationItem items[1];
char sysctlPath[] = [path fileSystemRepresentation]; // error on this line




On 24-Jul-05, at 2:40 PM, j o a r wrote:




On 24 jul 2005, at 18.56, Jerry Brace wrote:




I have a NSString set up like so:
NSBundle *thisBundle = [NSBundle bundleForClass:[self class]];
NSString * path = [thisBundle pathForResource:@"wakein" ofType:@""];


Now I need to assign "path" to:
char sysctlPath[]




You probably want to have a look at "-[NSString fileSystemRepresentation]":


<http://developer.apple.com/documentation/Cocoa/Reference/ Foundation/ObjC_classic/Classes/NSString.html#//apple_ref/doc/uid/ 20000154-fileSystemRepresentation>

j o a r







_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden





_______________________________________________ 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
  • Follow-Ups:
    • Re: NSString to char[]
      • From: Clark Cox <email@hidden>
    • Re: NSString to char[]
      • From: Will Mason <email@hidden>
References: 
 >NSString to char[] (From: Jerry Brace <email@hidden>)
 >Re: NSString to char[] (From: j o a r <email@hidden>)
 >Re: NSString to char[] (From: Jerry Brace <email@hidden>)
 >Re: NSString to char[] (From: John Stiles <email@hidden>)

  • Prev by Date: Re: NSString to char[]
  • Next by Date: Re: NSString to char[]
  • Previous by thread: Re: NSString to char[]
  • Next by thread: Re: NSString to char[]
  • Index(es):
    • Date
    • Thread