1

I've imported a Swift UIViewController in an Objective-C-based project and I've followed

and

My project doesn't crash, but I can't get a view to load. I'm attempting to instantiate a viewController, but it shows up as a white blank screen:

UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"mySwiftVC"];

I put a breakpoint in immediately after the prior line and po rootViewController gives a memory address.

I threw a println in the viewDidLoad of MySwiftVC, but nothing comes up. All the lights "are on", but nothing displays/executes. Any ideas where to look for resolution?

Here's the method where the prior line was called:

- (void)checkDisclaimer {
    UIStoryboard *storyboard = self.window.rootViewController.storyboard;

    if ([[[NSUserDefaults standardUserDefaults]valueForKey:@"disclaimerAcknowledged"]boolValue] == NO) {
        // set to instantiate disclaimer VC
        UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"disclaimer"];
        self.window.rootViewController = rootViewController;
        NSLog(@"Disclaimer IS NOT acknowledged");
    } else {
// this is the line that's working from a memory standpoint, but nothing happens
        UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"launchScreen"];
        self.window.rootViewController = rootViewController;
        NSLog(@"Disclaimer IS acknowledged");
    }
    [self.window makeKeyAndVisible];

}
Community
  • 1
  • 1
Adrian
  • 16,233
  • 18
  • 112
  • 180
  • And how are you presenting the view controller? – nhgrif Jul 23 '15 at 14:40
  • I'm not sure what you mean by that. It fills the screen. It worked before, but doesn't work with the `SwiftVC` even though I get a memory address for the `SwiftVC` – Adrian Jul 23 '15 at 14:46
  • @nhgrif is asking what code do you use to make sure the VC shows on screen – Robert J. Clegg Jul 23 '15 at 15:14
  • That code displays an Obj-C VC without a problem. Pointing it at the SwiftVC doesn't work, but it doesn't crash either. Kind of annoying – Adrian Jul 23 '15 at 15:16
  • I don't remember what I did in that particular project, but it's addressed here: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html in the section titled "To import Swift code into Objective-C from the same target". I think I ended up following those steps, cleaning cache, closing project, nuking derived data, and running it again. – Adrian Dec 15 '15 at 14:29

0 Answers0