I need to use a delegate object in an iOS application. I have declared the delegate as this:
In the class where the function is defined:
@interface OOObjectCommandInterface : NSObject<OOCameraControllerDelegate>
In the class where the function must be invoqued:
(In de .h file)
@protocol OOCameraControllerDelegate
- (void)drawFrame:(CVImageBufferRef) imageBuffer:(BOOL)flip;
@end
and
@interface OOCameraController : UIViewController
{
...
id<OOCameraControllerDelegate> delegate;
}
@property (nonatomic, readwrite) id<OOCameraControllerDelegate> delegate;
Aditionally, where the second class is initialized:
_hardwareController.delegate = [OOObjectCommandInterface ocInterface];
where _hardwareController is an instance of OOCameraController class.
So, when I try to invoque the delegate object, I do this:
[delegate drawFrame:imageBuffer:flip];
but the function is not executed. Any idea?
P.D.: The function I am calling is a singleton class. Could be any problem there?
By definition, a singleton is a design patron to access an object, unique, that only can be created 1 time (first get_instance you do). With get_instance, you can access from everywhere, to the functions inside the singleton, so, Why you are not using it directly?
Write something like [[MySingletonClass get_instance] FunctionThatIWantToUse:…]; And don’t use a delegate