Ich habe eine iOS App, die ich als "View-basierte App" in xCode erstellt habe. Ich habe nur einen viewController, aber es wird automatisch angezeigt, und ich sehe keinen Code, der es mit meinem appDelegate verbindet. Ich muss Daten von meinem AppDelegate zu meinem ViewController übergeben, aber ich weiß nicht, wie man das auszieht.Wie greife ich von meinem AppDelegate auf meinen viewController zu? iOS
Meine app delegate.h:
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSDictionary *queryStrings;
@end
Auch appDidFinishLoadingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[JMC sharedInstance] configureJiraConnect:@"https://cmsmech.atlassian.net/" projectKey:@"WTUPLOAD" apiKey:@"7fc060e1-a795-4135-89c6-a7e8e64c4b13"];
if ([launchOptions objectForKey:UIApplicationLaunchOptionsURLKey] != nil) {
NSURL *url = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey];
NSLog(@"url received: %@", url);
NSLog(@"query string: %@", [url query]);
NSLog(@"host: %@", [url host]);
NSLog(@"url path: %@", [url path]);
queryStrings = [self parseQueryString:[url query]];
NSLog(@"query dictionary: %@", queryStrings);
}
else {
queryStrings = [self parseQueryString:@"wtID=nil"];
}
return YES;
}
Entschuldigung, was ist in diesem Zusammenhang "selbst"? Beziehen Sie sich auf die Eigenschaft "-window" in UIApplicationDelegate? Wenn ja, nur iOS 5+ - nur ein Heads-Up. –
@ConradShultz Ja, es war die UIApplicationDelegate. Das ist wichtig zu wissen, Danke! – utahwithak
Ich bin nicht sicher, ob dies der beste oder einzige Weg ist, aber so habe ich es gewählt und es funktioniert gut. Vielen Dank. – HackyStack