char Array to NSString to cString?
char Array to NSString to cString?
- Subject: char Array to NSString to cString?
- From: Vince Ackerman <email@hidden>
- Date: Fri, 1 Jun 2007 08:15:27 -0700
I'm having a bit of trouble trying to convert an array of 7 (unsigned
char) to a NSString. I need to pass this array of hex values to
another object that is expecting an NSString that it will convert to
a C string and send it out the serial port using this function:
-(int)writeString:(NSString *)string
{
return write(fileDescriptor, [string cString], [string cStringLength]);
}
I need it to write these hex values exactly without any conversion or
encoding. I'm getting a bit lost (as a Newbie) as to how to convert
from an array to NSString then back again to c string since 10.4
deprecates all the cString methods. The methods I've tried seem to be
changing the hex values.
This is an example of hex numbers in myArray:
(unsigned char) myArray[7];
0xff 0x01 0x00 0x02 0x20 0x00 0x23
Can anyone help me understand how to do this?
Thanks in advance,
Vince
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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