2015-04-16 37 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

已更新我的問題代碼 –

回答