问题
I have been programming on iOS for almost six months now, using xibs left and right, but i am still unaware how loading process works...
What i mean, i have view controller and push button to open new modal view controller. From that point onwards how are things done. Is init method first called, then xib created, outlets connected and then nib loaded?
Is there any good article or book that explains this in details?
回答1:
Give this article a look: The View Controller Life Cycle
回答2:
this maybe not answer your question the way like you want, but i recommend you to find it out yourself.
How? see the text above.
- use
XLog()
in case ofNSLog()
- paste the code above in your prefix.pch file
- put in every method you want an
XLog()
statement and see, which methods are called firstly.
XLog()
is a better way of NSLog()
. In console you can see the Line numbers and the methodnames where the log is called. this should help you out to understand the way of loading nibs.
#define DEBUG 1
//#define RELEASE 1
#ifdef DEBUG
// Debug definitions
#define DEBUG_MODE
#define XLog(fmt, ...) NSLog(@"%s line:%d " fmt, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#ifndef RELEASE
#error DEBUG or RELEASE need to be #defined
#endif
// Release definitions
#define RELEASE_MODE
#define XLog(...)
#endif
来源:https://stackoverflow.com/questions/12194509/sequence-of-execution-when-loading-xib