Taming Snow Leopard: stringWithCString: length depreciation

I know this one has been depreciated in 10.5 to but i never found a nice replacement until now:

message = [NSString stringWithCString:(buffer + 4) length:(arg2 -5)];

becomes:

message = [[[NSString alloc] initWithBytes:(buffer + 4) length:(arg2 -5) encoding:NSASCIIStringEncoding] autorelease];

Advertisements
Tagged with: , ,
Posted in Code
4 comments on “Taming Snow Leopard: stringWithCString: length depreciation
  1. Justine Okin says:

    I wanted to thank you for this excellent post. I absolutely liked every little bit of it. I have you bookmarked and will be coming back.

  2. Donna says:

    Hey, thanks for the pointer to what to replace that deprecated function with.

    Cheers,
    Donna

  3. Krishen says:

    Thanks for this post… wish Apple could put stuff like this beside their deprecation notices.

  4. Bhakti says:

    Thanks a tonn for the exact replacement. Could not find it anywhere else. Saved a lot of time n effortt! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories
%d bloggers like this: