• 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
char Array to NSString to cString?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: char Array to NSString to cString?
      • From: Tomas FranzĂ©n <email@hidden>
    • Re: char Array to NSString to cString?
      • From: Douglas Davidson <email@hidden>
    • Re: char Array to NSString to cString?
      • From: Charles Steinman <email@hidden>
  • Prev by Date: Re: How do you get an NSCell subclass into a Palette?
  • Next by Date: Re: char Array to NSString to cString?
  • Previous by thread: Re: How do you get an NSCell subclass into a Palette?
  • Next by thread: Re: char Array to NSString to cString?
  • Index(es):
    • Date
    • Thread