Benifits of wakefulness?

I studied coredata, creating many simple test applications based on the xcode navigation controller template with a check for "use coredata".

The awakeFromNib method in the application delegate was a source of problems for me because I add other views to the controller and change the boot sequence, so the RootViewController can be a second or third choice.

I found out what awakeFromNib does, and I deleted it, so the application delegate is no longer tied to any particular kind. (Therefore, when I want to load the RootViewController, I load it as a regular view and use my own viewDidLoad to initialize the ObjectContext managed object for the view).

My question is: are there any performance benefits or other benefits using awakeFromNIb in AppDelegate? or is it just another way to do the same as me using the viewDidLoad method?

+7
source share
1 answer

All methods work at different times and in different circumstances.

awakeFromNib is called when the nib file associated with the class is loaded from disk. Any class that may have a tip can use it. viewDidLoad used only by view controllers. It is usually called when loading from nib, but it can also be called by a representation created in memory (a very rare circumstance.)

In any case, you only add functionality that you want to run only once when the instance is loaded first. For example. Nubia's common mistake is to put code in viewDidLoad , which should be run every time a view appears. Say, as with the main view, which opens the detailed view, and then reappears when the detailed view is rejected. If the main view code is in viewDidLoad , it will be run only the first time the main view is loaded, but not at subsequent times when the main view disappears and reappears.

Usually you do not initialize any other views or do anything in the delegate case of an application from nib. This is usually done in applicationDidFinishLaunching .

+5
source

All Articles