Get Applicationdidfinishlaunching Call in a View Controller. Parse Not Initialized Yet

Get applicationDidFinishLaunching call in a View Controller. Parse not initialized yet

You can add an observer for the UIApplicationDidFinishLaunchingNotification inside your view controller viewDidLoad method:

NotificationCenter.default.addObserver(self, selector: #selector(didFinishLaunchingNotification), name: UIApplication.didFinishLaunchingNotification, object: nil)

Add your method to the view controller

@objc func didFinishLaunchingNotification(_ notification: Notification) {
// your code
}

How do I give my parsing code access to my ManagedObjectContext?

You are creating an XMLParser object and setting its managed object context. This is fine.

However, then you release it. If you plan to use the object, you should not release it immediately.

UPDATE
You can pass the managed object context into your view controller(s) in applicationDidFinishLaunching:. You can also get it from the app delegate or another singleton that manages your Core Data stack.

You can get the managed object context from the app delegate like this:

[UIApplication sharedApplication].delegate.managedObjectContext

Parse PFUser not registering subclass

Reading some content on the internet I discovered that in OSX the ViewController is launched before the AppDelegate finishes loading, so I initialized the Parse connection and subclassing in the ViewController's viewDidLoad instead of AppDelegate and it is working just fine.

Obj-C & Cocoa: Variable is nil after applicationDidFinishLaunching:

Because as mentioned in the documentation

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification    

Sent by the default notification center after the application has been launched and initialized

Which means, I guess, that the application loads entirely, build all views and then call the method.

Is there any reason why you need your method call to occur after the application is loaded ?

to call method in viewdidload method

You can create parser in the class in witch you want to use it ... Or you can create Parser in one class and from another call it and gave the delegate of the class witch you want ...

iPhone - Issues accessing viewController variables from my delegate

Are you sure your viewController is not nil? Ok, that's unlikely. Then are you sure your donnees array is not nil AND it is NSMutableArray, but not NSArray?

And, btw, you CAN access the properties out of appDelegate from anywhere. I'm not fond of this solution, but just to make a clarification on that. In any class you can do smth like:

#include "YourAppDelegate.h"

- (void)someMethod {
YourAppDelegate *yourDelegate = [[UIApplication sharedApplication] delegate];
yourDelegate.donnees = self.anotherArray;
}

Of course, donnees should be a property in this case. Cheers!

iPhone application crash on launch

You are still blocking the main thread too long - be it during launch or later. Only do lightweight GUI work on the main thread. The main thread is also blocked if you perform work on a second thread but wait in your main thread for the results.

Instruments is your friend here.



Related Topics



Leave a reply



Submit