Link to home
Start Free TrialLog in
Avatar of deniro1974
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
ASKER CERTIFIED SOLUTION
Avatar of SpeedyApocalypse
SpeedyApocalypse
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of deniro1974
deniro1974

ASKER

can i use this in timer like every 1 sec for example it will not put traffic on the network or it will not make the Iphone or application became slow or something
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.
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.
now i tried the code you give to me and when the application start its crash any idea?
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];	

Open in new window