because i don’t want to use the NSDATE function of Xcode, i tried to override it with a php script…i found the solution here but it does not work or i can’t get it to work.
this is the code:
- (NSDate *) CurrentDate
{
if ([self hasInternetConnectivity]) // this tests Internet connectivity based off Apple's Reachability sample code
{
NSURL * scriptUrl = [NSURL URLWithString: @"http://<yoursite>.com/<the 2 line php script>.php"];
NSData * data = [NSData dataWithContentsOfURL: scriptUrl];
if (data! = nil) {
NSString * tempString = [NSString stringWithUTF8String: [data bytes]];
NSDate * currDate = [NSDate dateWithTimeIntervalSince1970: [tempString doubleValue]];
NSLog (@"String returned from the site is:% @ and date is:% @", tempString, [currDate description]);
return currDate;
} else {
NSLog (@ "nsdata download failed");
return [NSDate date];
}
} else {
NSLog (@ "InternetConnectivity failed");
return [NSDate date];
}
}
Whatever i do it returns errors as in hasInternetConnectivity does not exist in @interface etc..
i just pasted the code into the NAME.m file but it does not want to work..
what i am trying is to get the requested date (php time should return something like 20:10:40 ) in a text field.
its just a string…when someone pushes the button it should get the server time and put it in the text field…
what am i doing wrong ?
This is what i did, it works and it leaks a bit but don’t worry about it its too small:
this is a example of the phpfile to keep it simple: