NSString and Hexadecimal numbers
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