Reputation: 446
I have few buttons on screen. I need to calculate execution time when any ui element is pressed, but without adding that to every button. I have function that catches only View Controller touching.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSString * strLoad = @"";
for (int i = 1; i <=100000; i++) {
strLoad = [strLoad stringByAppendingString:@"add"];
}
NSLog(@"touchesBegan");
NSTimeInterval delta = ([[NSProcessInfo processInfo] systemUptime] - [(UIEvent*)event timestamp]);
NSLog(@"time %.2f", delta);
}
- (void)viewDidLoad {
[super viewDidLoad];
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)btnMetadata:(id)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=500; i++) {
strLoad = [strLoad stringByAppendingString:@"add"];
}
}
- (IBAction)btnGenerateCrash:(id)sender {
NSString * strLoad = @"aBC";
for (int i = 1; i <=5000; i++) {
strLoad = [strLoad stringByAppendingString:@"add"];
}
}
Upvotes: 2
Views: 121
Reputation: 2393
Hi you need work with like this hacker's method:
http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html
and some like this:
https://github.com/kennytm/iphone-private-frameworks
It is not very simple but it is possible. Good luck!
UDP similar question
How to send a touch event to iPhone OS?
Upvotes: 1