Re: Initializing a string with an NSData
Re: Initializing a string with an NSData
- Subject: Re: Initializing a string with an NSData
- From: Peter Ammon <email@hidden>
- Date: Fri, 29 Jun 2001 16:53:28 -0700
on 6/29/01 9:57 AM, Candide Kemmler at email@hidden wrote:
>
Hi,
>
>
The foundation docs states:
>
>
- (id)initWithData:(NSData *)data
>
encoding:(NSStringEncoding)encoding
>
>
Problem is: I don't know how to create a valid NSStringEncoding...
>
>
Sorry for the stupid question, I'm just a beginner. BTW, I'm looking for
>
a good introduction to Objective-C for a non-C programmer (I'm a Java
>
programmer). Don't really know how to handle the * thing (pointers...).
>
A super easy way to create an NSString from ASCII data stored in an NSData
is
NSString* myString=[NSString stringWithCString:[myData bytes] length:[myData
length]];
-Peter