Reputation: 2303
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?
Upvotes: 3
Views: 523
Reputation: 11930
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
Upvotes: 3
Reputation: 991
Have you set delegate to self in the second class? Create an object in the second class like
@property (nonatomic, readwrite) id<OOCameraControllerDelegate> delegate;
and then [_hardwareController setDelegate:self];
Upvotes: 4