0

I have the following header for ReaderViewController.h

#import <UIKit/UIKit.h>

#import "ReaderDocument.h"

@class ReaderViewController;

@protocol ReaderViewControllerDelegate <NSObject>

@optional // Delegate protocols

- (void)dismissReaderViewController:(ReaderViewController *)viewController;

@end

@interface ReaderViewController : UIViewController

@property (nonatomic, weak, readwrite) id <ReaderViewControllerDelegate> delegate;

- (instancetype)initWithReaderDocument:(ReaderDocument *)object;

@end

In a swift file

  class DetailTableViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource {


override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    // Get the row data for the selected row
    var phrase: String = "" ;

    var document:ReaderDocument? = ReaderDocument(filePath: "/Users/Krishna/Development/XXXX/Reader.pdf", password: phrase);
    if(document != nil){
        var readerViewController:ReaderViewController  = ReaderViewController(readerDocument: document)
        readerViewController.delegate = self ;
        readerViewController.modalTransitionStyle = .CrossDissolve;
        readerViewController.modalPresentationStyle = .FullScreen;
        self.presentViewController(readerViewController, animated: true, completion: nil)
    }

func dismissReaderViewController(viewController: ReaderViewController) {

    self.dismissViewControllerAnimated(true, completion: nil)

}


}

For the line readerViewController.delegate = self ; Xcode throws a compile time exception that

Type 'DetailTableViewController' does not conform to protocol 'ReaderViewControllerDelegate' . I tried looking for solutions for other similar posts and couldn't figure out the issue. Any help is appreciated as I am new developer in iOS platform!

1 Answer 1

1

Simply add ReaderViewControllerDelegate to the first line in your DetailTableViewController, as this tells the compiler, that this class conforms to the particular delegate protocol.

class DetailTableViewController: UITableViewController, UITableViewDelegate, UITableViewDataSource, ReaderViewControllerDelegate
Sign up to request clarification or add additional context in comments.

1 Comment

Your welcome :) Please mark this answer as accepted (green checkmark), to close this issue. Thank you.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.