Hello, i have problem calling a method using delegate. Pls take a look at my simplified code and tell me what's wrong.
Protocol declaration file:
Code:
// UpdateCurrentSumDelegate.h
#import <Foundation/Foundation.h>
@protocol UpdateCurrentSumDelegate <NSObject>
@required
-(void)UpdateCurrentSum;
@end
Header file of class that implements the protocol:
Code:
// Cube1ViewController.h
#import "UpdateCurrentSumDelegate.h"
@interface Cube1ViewController : UIViewController <UpdateCurrentSumDelegate>{
id <UpdateCurrentSumDelegate> delegate;
Cube1ViewController *cube1vc;
}
@property (nonatomic, assign) id delegate;
@end
Implementation file of class that implements the protocol:
Code:
// Cube1ViewController.m
#import "Cube1ViewController.h"
@implementation Cube1ViewController
@synthesize delegate;
-(Cube1ViewController *)cube1vc {
if (!cube1vc)
{
cube1vc=[[Cube1ViewController alloc]init];
}
return cube1vc;
}
- (void)viewDidLoad {
self.cube1vc.delegate = self;
[self.delegate UpdateCurrentSum];
}
-(void)UpdateCurrentSum {
NSLog(@"this doesnt gets called by delegate!!!");
}
So, what is wrong? Pls help me. Thanks.