Ios 在AppDelegate中设置TabviewController时使用UIViewController传递参数

Ios 在AppDelegate中设置TabviewController时使用UIViewController传递参数,ios,Ios,在选项卡栏中创建选项卡时,我希望将其与参数一起传递。每次应用程序启动时,这些参数都会更改。但是,在上的“UIViewController”类型的对象上找不到属性“passedURL” finalVC.passedURL = @"http://www.google.com"; 最终分类VC.h: @property(nonatomic, retain) NSString *passedURL; AppDelegate.m: #import "FinalCategoryVC.h" - (BOO

在选项卡栏中创建选项卡时,我希望将其与参数一起传递。每次应用程序启动时,这些参数都会更改。但是,在上的“UIViewController”类型的对象上找不到属性“passedURL”

finalVC.passedURL = @"http://www.google.com";
最终分类VC.h:

@property(nonatomic, retain) NSString *passedURL;
AppDelegate.m:

#import "FinalCategoryVC.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    UIViewController  *finalVC = [[[FinalCategoryVC alloc] initWithNibName:@"FinalCategoryVC" bundle:nil] autorelease];

    finalVC.passedURL = @"http://www.google.com";

    self.tabBarController = [[[UITabBarController alloc] init] autorelease];   
    self.tabBarController.viewControllers = @[finalVC]; 
   self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    self.tabBarController.customizableViewControllers = nil;
    return YES;
}

您之所以会出现此错误,是因为您正在使用此行将FinalCategoryVC强制转换为UIViewController

UIViewController  *finalVC = [[[FinalCategoryVC alloc] initWithNibName:@"FinalCategoryVC" bundle:nil] autorelease];
将其更改为此以解决问题

FinalCategoryVC  *finalVC = [[[FinalCategoryVC alloc] initWithNibName:@"FinalCategoryVC" bundle:nil] autorelease];