简体   繁体   中英

iOS - How do I pass arguments from didFinishLaunchingWithOptions to a viewController?

I want to know how can I pass arguments from the delegate didFinishLaunchingWithOptions to the first view controller whose view will be launched.

I didn`t find anything similar on the Internet.

Thank you in advance!

Try this:

myViewController = [[MyViewController alloc] init];
[myViewController setMyCoolFirstArgument: coolArgument];
[myViewController setMyCoolSecondArgument: coolSecondArgument];
[window setRootViewController: myViewController];

and in MyViewController.h

@property (nonatomic, retain) CoolArgument *myCoolFirstArgument;
@property (nonatomic, retain) CoolArgument *myCoolSecondArgument;

and in MyViewController.m

@synthesize myCoolFirstArgument, myCoolSecondArgument;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM