navigationDocument not found if initialized from objective c

Hi,



I'm trying to use an appdelegate written in objective c, but it seems that if I create a TVApplicationControllerContext from there, then I don't have access to navigationDocument in my js file:


2015-10-11 18:02:05.331 tv[2049:98356] ITML <Error>: Can't find variable: navigationDocument - http://localhost:9001/js/application.js - line:18:21


My code:


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    /
  
    TVApplicationController *appController;
    static NSString *TVBaseURL = @"http:/
    static NSString *TVBootURL = @"http:/
  
  
    UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    TVApplicationControllerContext *appControllerContext = [[TVApplicationControllerContext alloc] init];
  
    appControllerContext.javaScriptApplicationURL = [NSURL URLWithString:TVBootURL];
    [appControllerContext.launchOptions setValue:TVBaseURL forKey:@"BASEURL"];
  
    appController = [[TVApplicationController alloc] initWithContext:appControllerContext window:window delegate:self];
    return YES;
}



If I convert to a swift class, then everything works..


Any ideas? (I'm using xcode Version 7.1 beta 3 (7B85))

Replies

I guess appControllerContext.launchOptions is nil at init time and you have to assign some dictionary to it.

I am having the same issue. No love for objective-C I guess

appControllerContext.launchOptions is nil, I tried assign a NSDictionary to this launchOptions but still can't get things to work. Switching to Swift fixes. Weird problem.

You need to save the appController as instance-variable 😉

Both Obj-C and Swift are supported, as "goergisn" pointed out appController is not being saved and is required to be held for the life of the context.