views:

357

answers:

2

I have a very big integer value in decimal which i put in NSString , i need to convert to NSString of Bytes value for this big value how can i do it? FYI the length of NSSting is "308"

Please help

Thanks

+1  A: 

What do you mean "string of bytes"?

In particular, an NSString can only encapsulate strings with valid unicode (and some more primitive non-unicode) encodings. Thus, "string of bytes" may not actually make sense.

If you really want raw bytes, you can convert it to an NSData instance using the dataUsingEncoding:* methods (there are two, depending on need).

bbum
+2  A: 

To do this, you'll need to do the following(assuming you want a UTF8-encoded byte stream):

NSString *myString; //Assuming your string is here
NSData *stringData = [myString dataUsingEncoding:NSUTF8StringEncoding]; //This is the NSData representation of the string
const void *bytes = [stringData bytes]; //This are the raw bit array values
Mike