How to get Lauch time of an ios application - ios

I'm new to ios mobile testing. I need to get the launch time of an ios application. How would i do that using java or is there any other way to do it. Any advise on this would be helpful. Thanks in advance.

I don't think this is achievable in java since the iOS development is in Obj-C/Swift. However I'll answer your question.
You can get the launchDate DateTime.Now that start at the AppDelegate application:willFinishLaunchingWithOption and get the finishLoadDate DateTime.Nowon the ViewDidload method of the first View Controller that shows. And then compare these both dates to track the time difference.
This way you can track the time from the app was clicked, till the app was launched.
Hope that helps!

A lot of things happens before the system executes willFinishLaunchingWithOption.
So all you need to do in order to understand it, it's to set the environment variable DYLD_PRINT_STATISTICS.
Just click on edit scheme then select Run and set DYLD_PRINT_STATISTICS as and environment variable under arguments tab.
After that you will be able to see launching time in your debug console.

Haven't tested this, but it should help you get your solution:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSDate *fetchStart = [NSDate date];
NSDate *fetchEnd = [NSDate date];
NSTimeInterval timeElapsed = [fetchEnd timeIntervalSinceDate:fetchStart];
NSLog(#"Duration: %f seconds", timeElapsed);
return YES;
}
Hope this helps!

Related

NSDate not an Objective-C object?

This is one of those questions that is so absurdly simple that I can't believe I'm asking it on here. But, I'm stumped, so here I go: I'm trying to create an NSDate for a certain time in the future. I thought it was easy, but when I try:
NSDate *destinationDate = [NSDate dateWithTimeIntervalSinceNow:30];
a breakpoint at the following line says that destinationDate is "not an Objective-C object." I tried a million different versions, from this:
NSDate *destinationDate = [[NSDate alloc] init];
destinationDate = [NSDate dateWithTimeIntervalSinceNow:30];
to this:
NSDate *destinationDate = [NSDate date];
to this (suggested here):
NSDate *destinationDate = [[NSDate date] copy];
And nothing works! They're all "not Objective-C objects"! I'm sure it's something simple and embarrassing that I'm missing, but I am completely at a loss. Can someone help me out?
Well, you can see in the documentation here that NSDate is indeed a NSObject, which ofcourse is a Objective-C object.
This is probably a bug of the debugger panel, unfortunately it happens a lot. When this weird things happens, always use the console, when in a breakpoint, with a po myVariable to check the content of your variable, it's more reliable.
NSDate is a subclass of NSObject as per apple's documentation.
The methods you listed (alloc/init, and class method dateWithTimeIntervalSinceNow:) are valid uses.
It's hard to say more about it without knowing what your actual issue is, but if you are not using ARC, you might check that you retain/release correctly.
Are you using the variable after the breakpoint as well? Otherwise the object might already be released by the time you hit the breakpoint, because the app doesn't need it anymore. Then you'll get a "not an object" message.
Is Foundation not included in the project?
#include <Foundation/foundation.h>

orphaned UILocalNotification - confirmed

I have an app I am working on with allows the user to set and remove UILocalNotifications. In the course of developing this I have added and removed UILocalNotifications for testing and it seems to be working.
However I am seeing strange behavior where, after deleting my app from the device and running it again without setting any notifications, I will get a UILocalNotification. This notification was not set in this fresh install (checked through adding a breakpoint in my notification setup method).
Is it possible that I have an orphaned UILocalNotification from a previous install (yes, it seems highly unlikely to me too).
I've tried debugging this by setting the notification alertBody to something specific to each new install but this unique string doesn't get displayed in the alert. For example:
notif.alertBody = [NSString stringWithFormat:#"Alert for: %#", alertName];
Has anyone seen this sort of behavior before?
Update: Just confirmed orphaned UILocalNotifications: deleted the app from the device and ran the code below in my rootViewController on viewDidAppear. I get the following output in the Console:
2013-03-14 14:20:07.439 TestApp[16606:907] found alert: uigffhy
2013-03-14 14:20:07.444 TestApp[16606:907] found alert: uigffhy
Where this user was from some previous install. Ugh.
NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications];
for (UILocalNotification *notif in notificationArray) {
NSDictionary * info = notif.userInfo;
NSString * name = [info objectForKey:#"sequenceName"];
NSLog(#"found alert: %#", name);
}
Just detect if it's a fresh install (using NSUserDefaults) and do the following in applicationDidFinishLaunching:
[[UIApplication sharedApplication] cancelAllLocalNotifications];

DatePicker not returning selected date iOS

I am trying to get the selected date from a DatePicker and all I get is the current system date. Any ideas why?
I am doing it through the simulator as I do not have a device. Here is the code I use to get the date.
[self scheduleLocalNotification:timerPicker.date];
I have also used this to see if it works:
NSDate *d = [timerPicker date];
[self scheduleLocalNotification:d];
After several reboots of XCode and no code changes it magically started working.

Accessing the browsing history of iphone using webkit private framework

Hi I request please read the question completely before marking it as duplicate.
I am trying to get the iphone browsing history by using Webkit private framework.I get the headers for it from the github site. But I am not getting which headers or which methods to use to accomplish my task. I tried with the following code but its not returning anything not even null.
WebHistory *history=[WebHistory optionalSharedHistory];
NSDate *now = [NSDate date];
//id date;
NSArray *arr = [history orderedItemsLastVisitedOnDay:now];
NSLog(#"%#",[history allItems]);
I am writing in house app so i don't mind with this private framework. But i just can't go for jailbreaking. Please guide me the right way.
In order for the optionalSharedHistory method to return anything but null it must be instantiated and set like so in a place that's convenient in your application. Like a root view controller or the AppDelegate.
// Create a shared WebHistory object
WebHistory *myHistory = [[WebHistory alloc] init];
[WebHistory setOptionalSharedHistory:myHistory];
Hope this helps!

Time picker shows wrong time iphone sdk

I have time picker in my app. I'm showing timePicker.date and the time is wrong.
NSLog is
NSLog (#"date : %#",[timePicker.date description]);
log is like date: 2012-02-07 17:00:01 +0000
i think that problem is in timezone
in ViewDidLoad i have this code
timePicker.locale = [NSLocale currentLocale];
timePicker.timeZone = [NSTimeZone localTimeZone];
but it isn't working...
Can somebody help me to solve my problem. Thanks
It is likely that the time picker is correctly applying time zone, but you're logging it using GMT rather than local time so that it just looks wrong. If you want to display the time returned from your time picker using local time, use NSDate's descriptionWithCalendarFormat:timeZone:locale: method, or use the NSDateFormatter class to get complete control over how your date is displayed.

Resources