0

I have a view controller HomeController & BookController.I am going from view controller HomeController to BookController.I am passing data back to previous view controller.So i have used this approach.

#import <UIKit/UIKit.h>
#import "BaseController.h"
#import <MediaPlayer/MediaPlayer.h>
@protocol HomeProtocol
- (void)setComment:(BOOL)data;
-(void)setCommnetArray:(NSMutableArray*)data;
@end
@protocol BookProtocol
-(void)setBook:(BOOL)status;
@end
@interface HomeViewController : BaseController<UITableViewDataSource,UITableViewDelegate,HomeProtocol,UIScrollViewDelegate,BookProtocol,UINavigationControllerDelegate>
@property (weak, nonatomic) IBOutlet UITableView *table_view;
@property BOOL hasUserPostedComment;
@property NSInteger commentIndex;
@property (weak, nonatomic) IBOutlet UILabel *label_post_status;
@property UIRefreshControl *refreshControl;
@property NSInteger start_offset;
@property NSInteger end_offset;
@property (weak, nonatomic) IBOutlet UIButton *btn_refresh;
@property NSMutableArray *temp_user_cooments;
@property MPMoviePlayerController *moviePlayerController;
@property BOOL isBookMarkLoaded;

@end

BookMarkController.h

#import <UIKit/UIKit.h>
#import "BaseController.h"
#import "HomeViewController.h"
#import <MediaPlayer/MediaPlayer.h>

@protocol HomeProtocol
- (void)setComment:(BOOL)data;
-(void)setCommnetArray:(NSMutableArray*)data;
@end
@interface BookMarkController : BaseController<UITableViewDataSource,UITableViewDelegate,HomeProtocol,UIScrollViewDelegate>
@property (nonatomic, weak) id<BookProtocol> myDelegate;
@property (weak, nonatomic) IBOutlet UITableView *table_view;
@property BOOL hasUserPostedComment;
@property NSInteger commentIndex;
@property (weak, nonatomic) IBOutlet UILabel *label_post_status;
@property UIRefreshControl *refreshControl;
@property NSInteger start_offset;
@property NSInteger end_offset;
@property (weak, nonatomic) IBOutlet UIButton *btn_refresh;
@property NSMutableArray *temp_user_cooments;
@property MPMoviePlayerController *moviePlayerController;
@property NSString *index;

@end

Method implementation

-(void)setBook
{
    NSLog(@"set book called");
    self.isBookMarkLoaded=true;
}

It gives error Unrecognized selector sent to instance.Please tell me what is the issue here.

3
  • You need to add protocol to the BookMarkController.h. But in your code you have declared the protocol in HomeViewController.h. So you are getting that error
    – Raxit
    Nov 2, 2015 at 10:46
  • 1
    You just need a protocol in BookController defined.
    – Slavcho
    Nov 2, 2015 at 10:47
  • @Slavco Petkovski told you same thing. I had explain you step by step procedure, you need to follow the steps defined in my answer.
    – Raxit
    Nov 2, 2015 at 10:55

1 Answer 1

0

@protocol BookProtocol -(void)setBook:(BOOL)status; @end

Add above protocol to BookMarkController.h. Create delegate of the same in BookMarkController.h file. Make a call to -(void)setBook:(BOOL)status; from BookMarkController.m file

Add delegate in HomeViewController.h file. Define -(void)setBook:(BOOL)status; in HomeViewController.m file and also assign delegate to self.

That's all.

1
  • If my answer has solved your problem up vote for answer
    – Raxit
    Nov 3, 2015 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.