In my iPhone application…
Could not call the delegate method …
Here is my code
I have created a simple delegate in one class…
@protocol imagecelldelegate
-(BOOL) isIntersects:(CGRect)lastTouch;
@end
@interface ImageDemoGridViewCell : AQGridViewCell
{
id<imagecelldelegate> delegate;
}
@property (nonatomic,retain) id delegate;
@end
Now I have set the delegate in this class’s implementation and called the delegate method.
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self setDelegate:self.superview];
[delegate isIntersects:originalSelf];
//Getting error at this point...
}
After that I have implemented the method in the class which I have set the delegate..
@interface ViewController : UIViewController<imagecelldelegate>
{
And implemented the method in this class….
-(BOOL) isIntersects:(CGRect)lastTouch
{
NSLog(@"Delegate Yippee");
return YES;
}
This is the problem.
You should set the
ViewControlleras the reference for the delegate.For example, after you have allocated the
ImageDemoGridViewCellinViewController, set the delegate as follows.Then add the cell as subview to the
ViewControllers view.