我希望从当前时间到特定日期倒计时,并在标签中显示该值.我查看了一些NSTimer教程,但我无法弄清楚如何将它们应用到我的情况中.
NSTimeInterval TimeInterval = [aString doubleValue];
NSDate* upperDate = [aDate dateByAddingTimeInterval:TimeInterval];
NSDate* Today = [NSDate date];
//cell.myLabel.text = here i should write a countdown.
Run Code Online (Sandbox Code Playgroud)
对不起代码不足.我经常尝试写一些自己的代码,然后在这里提问,但这次我无法想象要写什么.
编辑 因此,PartiallyFinite的答案,我想我如何设置计时器.但因为我使用tableview,我无法实现MyTimerLabel的重复消息.这就是我刚刚做的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MyCell";
MekanListesiViewCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
aClass *aC = [myArray objectAtIndex:indexPath.row];
NSTimeInterval TimeInterval = [aC.aTimeIntervalwithString doubleValue];
NSDate* UpperDate = [aC.aNSDate dateByAddingTimeInterval:TimeInterval];
NSDateFormatter …Run Code Online (Sandbox Code Playgroud)