我有time在string例如格式2:00.我想NSDate用现在把它初始化date.我试过了
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setHour:2];
Run Code Online (Sandbox Code Playgroud)
我无法将其与日期对象进行比较.请帮忙
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
locmanager = [[CLLocationManager alloc] init];
[locmanager setDelegate:self];
[locmanager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
//[locmanager setDistanceFilter:10];
updateTimer = [NSTimer timerWithTimeInterval:600 target:self selector:@selector(startUpdating) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:updateTimer forMode:NSDefaultRunLoopMode];
[window makeKeyAndVisible];
return YES;
}
-(void)startUpdating
{
[locmanager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if (newLocation.horizontalAccuracy < 0) return;
CLLocationCoordinate2D loc = [newLocation coordinate];
currentdate=[[NSDate date]timeIntervalSince1970];
latitude = [NSString stringWithFormat: @"%f", loc.latitude];
longitude= [NSString stringWithFormat: @"%f", loc.longitude];
//Call to …Run Code Online (Sandbox Code Playgroud)