Reputation: 3
Hi I am using delegate methods in Objective C and need some help. I have the following functions A and B. B is the delegate function.
-(BOOL) A{
int cmd = 73;
[_serialPort sendData:cmd];
NSLog("Hello");
return TRUE;
}
//Delegate function
-(void) B{
//When some data is received on the serial port function B is called
}
But function A doesn't wait until data is received on the serial port. How do I block function A until some data is received on the serial port? I am using ORSSerialPort library in objective-C.
Upvotes: 0
Views: 128
Reputation: 7341
It looks like ORSSerialPort already uses a delegate for when you receive data.
- (void)serialPort:(ORSSerialPort *)serialPort didReceiveData:(NSData *)data {
// Assuming the delegate has method A
[self A];
}
-serialPort:didReceiveData:
is the delegate method from ORSSerialPort.
The code above will basically wait until data is received, and then once it happened, it will call A.
Upvotes: 1