Assigning Binary Data From Network To Variables
Assigning Binary Data From Network To Variables
- Subject: Assigning Binary Data From Network To Variables
- From: "Bridger Maxwell" <email@hidden>
- Date: Sat, 5 Jan 2008 00:27:41 -0700
Hello,
I am very new to Cocoa, so I apologize if this question seems very basic.
Right now I am trying to read data from a program that is sending data in
the "TUIO" protocol. I have read the data from the socket, and assigned it
to a NSData object with this code:
NSData *messageData = [[notification userInfo]
objectForKey:NSFileHandleNotificationDataItem];
Now how do I translate that data to integer and float values? I have sample
code from C++ and Java, but I don't know how to translate them to Cocoa. In
Java, it looks like this:
Object[] args = message.getArguments();
String command = (String)args[0];
String address = message.getAddress();
int s_id = ((Integer)args[1]).intValue();
int f_id = ((Integer)args[2]).intValue();
float x = ((Float)args[3]).floatValue();
float y = ((Float)args[4]).floatValue();
In C++ it looks like this:
ReceivedMessageArgumentStream args = msg.ArgumentStream();
ReceivedMessage::const_iterator arg = msg.ArgumentsBegin();
int32 s_id, f_id;
float xpos, ypos, angle, xspeed, yspeed, rspeed, maccel,
raccel;
args >> s_id >> f_id >> xpos >> ypos >> angle >> xspeed >>
yspeed >> rspeed >> maccel >> raccel >> EndMessage;
I would also be happy on a hint on what framework to use to do something
like this, but right now I am not even sure where to start looking.
Thank You,
Bridger Maxwell
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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