hi, i am using apple's sample URLCache,but when i mention url, it loads data perfectly but i want to calculate time of downloading(till completion),is there anyh built in method?
+1
A:
Add NSDate property to your class, name it,let's say, downloadStart and when download starts, save actual time to it - self.downloadStart = [NSDate date];
Then in -connectionDidFinishLoading: delegate method implementation do:
NSDate *downloadEnd = [NSDate date];
NSTimeInterval totalTime = ([downloadEnd timeIntervalSince1970] - [downloadStart timeIntervalSince1970]);
//Total time now contains number of seconds since download start time
NSLog(@"Download finished in %f seconds", totalTime);
self.downloadStart = nil;
That's it. Please note that the code above is just a kind of abstract how to do the trick, so don't use in copy & paste manner.
Matthes
2010-03-23 13:51:50