• 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
Assigning Binary Data From Network To Variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Assigning Binary Data From Network To Variables
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Undo after deletion
  • Next by Date: Re: thread protocol modifiers
  • Previous by thread: Re: Undo after deletion
  • Next by thread: Re: Assigning Binary Data From Network To Variables
  • Index(es):
    • Date
    • Thread