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:
#define UIALERTVIEW_TAG_REBOOT 1
#import "SUOTAViewController.h"
@interface SUOTAViewController ()
@end
@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];
} ...
I have already set the class of the ViewController in the storyboard to "SUOTAViewController" which matches that of my Obj-C ViewController. I am still getting the error.