• 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
NSString and Hexadecimal numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSString and Hexadecimal numbers


  • Subject: NSString and Hexadecimal numbers
  • From: Vince Ackerman <email@hidden>
  • Date: Fri, 25 May 2007 09:22:49 -0700

I'm trying to read data off a serial port and need to see the actual hex numbers in a Textview. I've looked at NSFormatter and the NSString format options but don't really understand how to use them. The read data should be in 7 byte packets so I'd like each packet to display as one line in the Textview.


This is part of my read data method:

SerialPortObj *sendPort = [dataDictionary objectForKey:@"serialPort"];
NSData *data = [dataDictionary objectForKey:@"data"];
if ([data length] > 0) {
[logText insertText:[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]];
// continue listening
[sendPort readDataInBackground];
} else { // port closed
[logText insertText:@"no data read\r"];



I'm not sure how to get the NSData formatted correctly. NSString has some formatting options which would seem to make the string obj a hex number but I can't figure out how to make this happen.



Can anyone give me a direction to go?


Vince (type slow please cause I'm a Newbie) _______________________________________________

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: NSString and Hexadecimal numbers
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: unexpected unicode behavior
  • Next by Date: Re: NSTreeController bound selection issue
  • Previous by thread: Re: unexpected unicode behavior
  • Next by thread: Re: NSString and Hexadecimal numbers
  • Index(es):
    • Date
    • Thread