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];
}
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.