Created
December 14, 2014 11:48
-
-
Save zhongge/612290f89dd43af10034 to your computer and use it in GitHub Desktop.
Q6. Get launched time of Application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Any time is printed in Console. It isn't application start time. | |
+ initialize method may not invoked or lazily invoked. | |
So if you need the launched time of application, you must write the code in main function. | |
- AppDelegate.m | |
NSString * startTime; | |
- main.m | |
extern NString *startTime; | |
int main(int argc, char* argv[]) { | |
@autoreleasepool { | |
NSDateFormatter *formatter = [NSDateFormatter new]; | |
formatter.dateStyle = NSDateFormatterNoStyle; | |
formatter.timeStyle = NSDateFormatterMediumStyle; | |
startTime = [formatter stringFromDate:[NSDate date]]; | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment