i’ve got own delegate for my own class.
MainMenuViewDelegate
#import <Foundation/Foundation.h>
@class MainMenuView;
@protocol MainMenuViewDelegate <NSObject>
-(void) mainMenuViewLibrary:(MainMenuView*)controller withString:(NSString*)string;
@end
MainMenuView.h
#import <UIKit/UIKit.h>
#import "WorkspaceView.h"
#import "MainMenuViewDelegate.h"
@interface MainMenuView : UIView
@property (nonatomic,weak) id <MainMenuViewDelegate> delegate;
....
@end
MainMenuView.m
@implementation MainMenuView
@synthesize delegate;
...
-(void)library:(id)sender{
//test
NSLog(@"it's work");
NSString *string = @"some text";
[delegate mainMenuViewLibrary:self withString:string];
NSLog(@"finish");
}
WorkspaceView.h
#import <UIKit/UIKit.h>
#import "MainMenuViewDelegate.h"
@interface WorkspaceView : UIView <MainMenuViewDelegate> {
int menuStatus;
UILabel *label;
}
@property int menuStatus;
@property (nonatomic, retain) UILabel *label;
@end
WorkspaceView.m
#import "WorkspaceView.h"
#import "MainMenuView.h"
@implementation WorkspaceView
@synthesize menuStatus;
@synthesize label;
....
-(void) mainMenuViewLibrary:(MainMenuView*)controller withString:(NSString*)string{
[label setText: string];
}
@end
The problem appears when i press btnLibrary and invokes -(void)library:(id)sender function.
console print it's work, then my delegate function is invokes, but i don’t see any change in my label (placed in WorkspaceView), and in finish console print finish.
None of your objects is set as the delegate so the delegate is nil – messages sent to nil are silenced. Nothing happens.
If it is not a problem, put the NSLog in:
in your WorkspaceView and check whether the method is called.
Hope that helps.