deniro1974
asked on
getting current time from server on iphone
Dear All,
am trying to write application for iphone this application shows current time and date but not from the iphone i need to get it from server for example microsoft windows server.
Best regards
am trying to write application for iphone this application shows current time and date but not from the iphone i need to get it from server for example microsoft windows server.
Best regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are downloading the data synchronously, so it will lag the main thread.
You can just transform the data you download into an NSDate object and increment that each second, hence increasing the server time without redownloading.
You can just transform the data you download into an NSDate object and increment that each second, hence increasing the server time without redownloading.
ASKER
how we can increment it as i understand i can get the time one time in the application lunch ans start to increment it every seconds but how i can do this
Look into the NSDateFormatter and NSDate class reference. If you have code issues, post your code and I can assist with it.
ASKER
now i tried the code you give to me and when the application start its crash any idea?
ASKER
thanks very much its working now but i had to use the below code
NSData *dataurl = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://example.com"]] ;
NSString *ahmad = [[NSString alloc] initWithData:dataurl encoding:NSUTF8StringEncoding];
ASKER