appdelegate

What describes the Application Delegate best? How does it fit into the whole concept?

江枫思渺然 提交于 2019-11-27 03:40:24
I think to know what the App Delegate does. It has some nice methods like -applicationDidFinishLaunching which will be called when the app has finished launching, and so on. But what's that actually? Is that some object instantiated in the UIApplicationMain function? And how does it work that every class in my app has access to that App Delegate object? Is there any good graph on the net that visualizes these relationships? In Cocoa, a delegate is an object that another object defers to on questions of behavior and informs about changes in its state. For instance, a UITableViewDelegate is

Open a view controller when a iOS push notification is received

末鹿安然 提交于 2019-11-27 03:21:25
I want to open a specific view controller when a user clicks on the received push notification message, but when I receive a push notification message and click the message, only the application opens, but it does not redirect to a specific view controller. My code is -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { if (applicationIsActive) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Bildirim" message:[NSString stringWithFormat:@"%@ ",[[userInfo objectForKey:@"aps"] objectForKey:@"alert"]] delegate:self

Get device token for push notification

核能气质少年 提交于 2019-11-27 02:45:06
I am working on push notifications. I wrote the following code for fetching a device token. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Add the view controller's view to the window and display. [self.window addSubview:viewController.view]; [self.window makeKeyAndVisible]; NSLog(@"Registering for push notifications..."); [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; return

Watchkit , openParentApplication with WatchKit Extension

风格不统一 提交于 2019-11-27 02:18:55
First times doesn't work "Null" ( before open App in iPhone ) and some times doesn't work but i want one loop or timer for repeat this request for get result : here is my code - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply { // Temporary fix, I hope. // -------------------- __block UIBackgroundTaskIdentifier bogusWorkaroundTask; bogusWorkaroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [[UIApplication sharedApplication] endBackgroundTask:bogusWorkaroundTask

Opening ViewController In AppDelegate While Keeping Tabbar

家住魔仙堡 提交于 2019-11-26 23:32:44
问题 In my Xcode project when a user taps on a notification I want to first send them to a certain item in my tabBar then I want to instantiate a view controller and send an object over to that view controller. I have code the that sends them to the tabBar I want, but I do not know how to instantiate them to the view controller while keeping the tabBar and navigation bar connected to the view controller. All the answers on this require you to change the root view controller and that makes me lose

How to get managedObjectContext for viewController other than getting it from appDelegate?

天涯浪子 提交于 2019-11-26 22:21:16
问题 Recently I came to know that "You really shouldn't be calling down to the AppDelegate to get the managed object context". Apple also has put this recommendation into their documentation here. It goes like this : A view controller typically shouldn’t retrieve the context from a global object such as the application delegate—this makes the application architecture rigid. Neither should a view controller create a context for its own use (unless it’s a nested context). This may mean that

iOS - Calling App Delegate method from ViewController

一世执手 提交于 2019-11-26 21:11:15
What I am trying to do is click a button (that was created in code) and have it call up a different view controller then have it run a function in the new view controller. I know it could be done relatively easily in IB but that isn't an option. An example of what I want to do would be if you had two view controllers one with a splash screen of house. The other view controller had a walk through of the house on it that you could go through all the rooms in a set order. The splash screen would have buttons for each room that would allow you to jump to any point on the walk through. You can

AppDelegate, rootViewController and presentViewController

爱⌒轻易说出口 提交于 2019-11-26 20:06:12
I'm doing the Facebook integration tutorial, I want to show my MainViewViewController if the user has a valid token for the current state otherwise I want to show LoginViewController. MainViewAppDelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) { // To-do, show logged in view } else { // No, display the login page. [self showLoginView]; } return YES; } - (void)showLoginView { UIStoryboard *mainstoryboard = [UIStoryboard storyboardWithName:@

NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

元气小坏坏 提交于 2019-11-26 17:28:29
In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error comes? NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle /Users/XXXXXXXXXXXX/Library/Application Support/iPhone simulator/6.0/Applications/ B7A7D461-1CFE-4B05-AF32-00B65FCFFF49/XXXXXXXXXX.app> (loaded)'with name 'RootViewController'' *** First throw call stack: (0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418

Present UIAlertController from AppDelegate [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 16:39:17
问题 This question already has answers here : How to present UIAlertController when not in a view controller? (33 answers) Closed 2 years ago . I'm trying to present a UIAlertController from the AppDelegate in my iOS app. Below is the alert and the present method. UIAlertController *alert = [UIAlertController alertControllerWithTitle:cTitle message:cMessage preferredStyle:UIAlertControllerStyleAlert]; //Configure alert and actions [self.window.rootViewController presentViewController:alert