• 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: Base64 encoding and deprecated stringWithCString: length:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Base64 encoding and deprecated stringWithCString: length:


  • Subject: Re: Base64 encoding and deprecated stringWithCString: length:
  • From: Clark Cox <email@hidden>
  • Date: Wed, 7 Oct 2009 22:02:24 -0700

On Mon, Oct 5, 2009 at 8:28 AM, Nala Gnirut <email@hidden> wrote:
> Hi all,
> I'm trying to use in a new Cocoa project base64 code sample from here:
>
> http://snipurl.com/sc6wd
>
> Part of the code adopts deprecated + (id)stringWithCString:(const char
> *)cString length:(NSUInteger)length
>
> so I'm replacing
>
> long base64Length = BIO_get_mem_data(mem, &base64Pointer);
> NSString * base64String = [NSString stringWithCString: base64Pointer length:
> base64Length];
>
> with
>
> NSString * base64String = [NSString stringWithCString: base64Pointer
> encoding: NSUTF8StringEncoding];

Because the stringWithCString:... methods expect C strings (i.e.
NUL-terminated strings). Instead, use:

NSString * base64String = [[[NSString alloc] initWithBytes:
base64Pointer length: base64Length encoding: NSASCIIStringEncoding]
autorelease];

--
Clark S. Cox III
email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Base64 encoding and deprecated stringWithCString: length: (From: Nala Gnirut <email@hidden>)

  • Prev by Date: Re: app delegate +initialize
  • Next by Date: Re: IB creating NULL outlet...
  • Previous by thread: Base64 encoding and deprecated stringWithCString: length:
  • Next by thread: Objective Lua
  • Index(es):
    • Date
    • Thread