小编agu*_*pta的帖子

使用特定时间初始化NSDate对象

我有timestring例如格式2:00.我想NSDate用现在把它初始化date.我试过了

   NSDateComponents *comps = [[NSDateComponents alloc] init];
   [comps setHour:2];
Run Code Online (Sandbox Code Playgroud)

我无法将其与日期对象进行比较.请帮忙

iphone nsdate

10
推荐指数
1
解决办法
1万
查看次数

每10分钟发送一次数据

 - (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)

iphone

3
推荐指数
1
解决办法
1218
查看次数

标签 统计

iphone ×2

nsdate ×1