Recieving data in an XCode program using ORSSerialPort

A spot for any other misc. programing languages not covered above.
Post Reply
jpWA
Posts: 46
Joined: Feb 9th, 2013, 10:07 am
Location: Atlanta, Ga, USA

Recieving data in an XCode program using ORSSerialPort

Post by jpWA »

First post!
I am trying to send data to my mac from an arduino that operates a joystick. I have an objective-c command-line tool in Xcode that uses the ORSSerialPort library.
I copied this piece of code from here https://github.com/armadsen/ORSSerialPort, it's supposed to read incoming data.

Code: Select all

- (void)serialPort:(ORSSerialPort *)serialPort didReceiveData:(NSData *)data
{
    NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
It gives me an error on the first line that says "missing context for method declaration" and doesn't seem to recognize the instance of NSString declared inside the braces later in the program
I really don't understand this syntax and could use some help from someone who knows objective-c

1. Is it initializing new instances of ORSSerialPort and NSData or using objects that are already declared?
2. If you can't use the string declared inside the braces anywhere else, and the whole thing returns void, how does it store the data?
3. didReceiveData is a method of the delegate protocol called ORSSerialPortDelegate, but besides that, I really don't understand what it is doing.
Post Reply