I am new to IOS, and Trying to pass two values form a UIViewController to a UIView. I followed few examples,some posts, tried and still no luck. I am getting this error while running the application. The error is ..
[MenuComponent setDelegate:]: unrecognized selector sent to instance
MenuComent is My UIView. FullVC is my UIViewController.
FullVC.h
@class FullVC;
@protocol MenuComponentDelegate <NSObject>
-(void)shareToView:(NSString *)titleString inUrl:(NSString *)urlString;
@end
@interface FullVC:UIViewController<UIScrollViewDelegate,UITextViewDelegate>
@property (nonatomic,assign) id delegate;
@end
FullVC.m
@interface FullVC ()
@end
@implementation FullVC
@synthesize delegate;
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(void)scrollViewInit
{
[self.delegate shareToView:title.text inUrl:urlString];
}
@end
MenuComponent.m
@interface MenuComponent()
@end @implementation MenuComponent
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.nav_controller.topViewController isKindOfClass:[FullVC class]])
{
if (indexPath.row==0)
{
[(FullVC *)self setDelegate:self];
}
}
}
-(void)shareToView:(NSString *)titleString inUrl:(NSString *)urlString
{
NSLog(@"title string after passing is: %@", titleString);
NSLog(@"url string after passing is: %@", urlString);
}
@end
I am getting error at this statement.
[(FullVC *)self setDelegate:self];
can somebody please help.
Thanks
self
as the delegate ofself
? I think you need to rethink that... – Cassius