Being a beginner I am finding it very hard to understand delegates, so I'll try to ask my question as good as I can:
I want Connection.m to be the delegate of Controller.h. In my Controller.h I have
@protocol HeliControllerDelegate <NSObject>
@optional
- (void) measurementUpdated:(NSNumber *) measurement;
- (void) didDiscoverCharacteristic; // neh
@end
@interface HeliController : UIViewController <CBPeripheralDelegate>
@property (nonatomic, assign) id<HeliControllerDelegate> delegate;
@end
and synthesize in Controller.m :
@synthesize delegate = _delegate;
before the interface decleration. In Controller.m I invoke didDiscoverCharacteristic with
- (void) peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error{
NSLog(@"Did discover characteristic for service %@", [service.peripheral UUID]);
for(CBCharacteristic *c in [service characteristics]){
if([[c UUID] isEqual:HeliController.throttleCharacteristicUUID]){
NSLog(@"Found throttle characteristic");
self.throttleCharacteristic = c;
[self.delegate didDiscoverCharacteristic];
}
}
}
In the delegate file Connection.h I start with
@interface Connection : UIViewController <CBCentralManagerDelegate, ControllerDelegate> {
}
so that I can use the methods from Controller.h's protocol, but even thoug the program executed the didDiscoverCharacteristic call nothing happens on the method implementation in Connection.m.
All help on this is really appreciated.