ios – How do I instantiate Storyboard ViewController?


I have objc code (SUOTAViewController) that I am including in my Swift project. I also have a storyboard associated with that ViewController with the storyboardID “suotaViewController”.

When I try to instantiate it like this:

func navigateToUpdateViewController(imageURL: URL) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "suotaViewController") as! SUOTAViewController
        vc.imageURL = imageURL
        self.navigationController?.pushViewController(vc, animated: true)

I get an error “Could not cast value of type ‘UIViewController’ to ‘SUOTAViewController’

Why is this happening?

Here is my SUOTAViewController if it helps:


#import "SUOTAViewController.h"

@interface SUOTAViewController ()


@implementation SUOTAViewController

@synthesize blockSize;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.textView.text = @"";
    storage = [ParameterStorage getInstance];
    manager = storage.manager;
    storage.file_url = self.imageURL;
    [self.progressView setProgress:0];
    [self.progressTextLabel setText:[NSString stringWithFormat:@"%d%%", 0]];
    // Enable notifications on the status characteristic
    [manager setNotifications:GenericServiceManager.SPOTA_SERVICE_CBUUID characteristicUUID:GenericServiceManager.SPOTA_SERV_STATUS_CBUUID enable:YES];
} ...