0
我從服務器獲得響應,其中我得到一個帶有time的NSDate參數。我在導航欄上有一個通知按鈕。無論什麼時候我們獲得45分鐘我們必須顯示通知按鈕的調查計數。按下按鈕後,用戶填寫包含調查問題的調查。但在45分鐘之前,用戶可以看到通知。在頁面加載後45分鐘後在按鈕上顯示通知
現在我的代碼看起來像這樣
-(void)checkForResponse:(HRNetworkDataModel *)dataModel
{
[HRUtility stopActivityIndicatorFromView:self.navigationController.view];
if ([dataModel.responseData[@"community_details"][@"status"][@"message"]isEqualToString:@"successful"])
{
self.pendingSurveyArray = dataModel.responseData[@"community_details"][@"data"][@"community_details"];
NSMutableArray *finalSurveyArray = [[NSMutableArray alloc] init];
for (NSInteger i=0; i<self.pendingSurveyArray.count;i++)
{ NSDictionary *tDict = self.pendingSurveyArray[i];
if((([tDict[@"survey_flag"] isEqualToNumber:[NSNumber numberWithBool:0]]) || [tDict[@"survey_flag"] isEqualToNumber:[NSNumber numberWithBool:0]]) ||[tDict[@"survey_flag"] isEqualToNumber:[NSNumber numberWithBool:0]])
{
[finalSurveyArray addObject:tDict];
self.communityVisitedDate = tDict[@"visited_time"];
}
}
if (finalSurveyArray.count == 0)
{
return;
}
else
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 45 *60 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self.navigationItem.rightBarButtonItems[0] setBadgeValue:[NSString stringWithFormat:@"%lu",(unsigned long)finalSurveyArray.count]];
});
}
}
}
任何幫助將不勝感激。