2015-04-16 103 views
0

我正在检查iOS中解析两个条件。在解析中,我主要有两个班级钥匙(班级名称app),钥匙是uuidexpiryDate这些解析查询在iOS中无法正常工作?

    1. 检查用户的唯一ID(UUID)是在解析或不可用。
  • 检查expiryDate字段对应于UUID比当前日期和时间在GMT更大。

但是当我尝试下面的查询它仅检查第一个条件 第二时间检查没有发生。

代码

NSString *udid = [[UIDevice currentDevice] uniqueDeviceIdentifier]; 

    NSDate *currentDate = [NSDate new]; 
    NSDate *localDate = currentDate; // get the date 

    NSTimeInterval timeZoneOffset = [[NSTimeZone defaultTimeZone] secondsFromGMT]; // You could also use the systemTimeZone method 

    NSTimeInterval gmtTimeInterval = [localDate timeIntervalSinceReferenceDate] - timeZoneOffset; 

    NSDate *gmtDate = [NSDate dateWithTimeIntervalSinceReferenceDate:gmtTimeInterval]; 

    PFQuery *wawQuery = [PFQuery queryWithClassName:@"app"]; 
    [wawQuery whereKey:@"udid" equalTo:udid]; 
    [wawQuery whereKey:@"expiryDate" greaterThan:gmtDate]; //checking not working 

    [wawQuery findObjectsInBackgroundWithBlock:^(NSArray *users, NSError *error) { 


    NSLog(@"user-->%@",[[users valueForKey:@"expiryDate"] objectAtIndex:0]); 
    NSDate *serverDate=(NSDate *)[[users valueForKey:@"expiryDate"] objectAtIndex:0]; 
    if([users count]>0){ 
     if([gmtDate compare:serverDate]==NSOrderedAscending){ 
      NSLog(@"not expired"); 
      sharedManager.status=true; 
      liveController *rxObj= [self.storyboard instantiateViewControllerWithIdentifier:@"live"]; 
      [self.navigationController pushViewController:rxObj animated:YES]; 

     }else{ 
      NSLog(@"expired"); 
      sharedManager.status=false; 
      [self initiateControlls]; 
     } 


    }else{ 
     sharedManager.status=false; 
     [self initiateControlls]; 
    } 

我期待一个日期检查这样

为如19-04-2015 21时二十分00秒和22时00分04秒19-04-2015,但

当我使用

if([gmtDate compare:serverDate]==NSOrderedAscending){ 

    } 

仅日期检查(19-04-2015到19- 04-2015 22时00分04秒),我想这两个日期时间检查(19-04-2015 21点20分○○秒至19-04-2015)

+0

更具体地说明您的问题。什么没有发生呢? – soulshined

+0

现在只有日期部分正在检查其没有照顾的时间 –

+0

已更新我的问题代码 –

回答