当前位置: 首页 > 编程日记 > 正文

iOS 在每一个cell上添加一个定时器的方案

1 首先创建一个数组,用来创建所有的定时器的时间

- (NSMutableArray *)totalLastTime
{if (!_totalLastTime) {_totalLastTime = [NSMutableArray array];}return _totalLastTime;
}

2 当从网络请求过来时间之后,循环遍历,行数和时间作为Key,将值作为value放进字典中放进数组

            // 所有剩余的时间  lastTimefor (int i = 0; i < strongSelf.bigModel.activeTeamList.count; i ++) {NSDictionary *dic = strongSelf.bigModel.activeTeamList[i];NSDate *date = [SKTool changeTimeStringtoDate:dic[@"EndTime"]];double time =  [date timeIntervalSinceDate:[NSDate date]];NSMutableDictionary *para = [NSMutableDictionary dictionary];[para setValue:@(i) forKey:@"row"];[para setValue:[NSNumber numberWithDouble:time] forKey:@"lastTime"];[self.totalLastTime addObject:para];}

3 没定时器更新的方法中去取出row 和 时间,更新到cell 上面去,然后再将更新过的时间更新到数组中去。

- (void)refreshLessTime {NSUInteger time;for (int i = 0; i < self.totalLastTime.count; i++) {time = [[[self.totalLastTime objectAtIndex:i] objectForKey:@"lastTime"]integerValue];NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[[[self.totalLastTime objectAtIndex:i] objectForKey:@"row"] integerValue] inSection:1];BaoPinCellA *cell = (BaoPinCellA *)[self.tableView cellForRowAtIndexPath:indexPath];cell.timeLbL.text = [NSString stringWithFormat:@"剩余:%@",[self lessSecondToDay:--time]];NSDictionary *dic = @{@"row": [NSString stringWithFormat:@"%li",(long)indexPath.row],@"lastTime": [NSString stringWithFormat:@"%lu",(unsigned long)time]};[self.totalLastTime replaceObjectAtIndex:i withObject:dic];}
}

相关文章:

用字符串生成二维码

需要导入Zxing.jar包import android.graphics.Bitmap;import com.google.zxing.BarcodeFormat; import com.google.zxing.MultiFormatWriter; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix;public class ZxingCode {/** * 用字符串生成…

在JavaScript中重复字符串的三种方法

In this article, I’ll explain how to solve freeCodeCamp’s “Repeat a string repeat a string” challenge. This involves repeating a string a certain number of times.在本文中&#xff0c;我将解释如何解决freeCodeCamp的“ 重复字符串重复字符串 ”挑战。 这涉及重…

杭电2099 整除的尾数

题目链接&#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid2099 解题思路&#xff1a;将a扩大100倍之后&#xff0c;再给它从加上i(i从0到99)&#xff0c;一个一个的看哪一个能整除 反思&#xff1a;末两位是00的时候输出的是00&#xff08;这种情况题目里面的测试数据给…

iOS 验证码倒计时按钮

具体使用 [SmsTimerManager sharedManager].second (int)time; [[SmsTimerManager sharedManager] resetTime]; [SmsTimerManager sharedManager].delegate self; [strongSelf updateTime];设置代理方法 更新按钮的标题 (void)updateTime { if ([SmsTimerManager sharedMan…

树莓派centos安装的基本配置

萌新再发一帖&#xff0c;这篇文章呢主要是为大家在树莓派上安装centos以后提供一个问题的解决方案。 首先我呢觉得好奇就在某宝上花了两百来块钱买了一套树莓派&#xff0c;很多人喜欢在树莓派上安装Debian&#xff0c;我呢更青睐用Red Hat的系统&#xff0c;毕竟对Red Hat更熟…

token拦截器阻止连接_如何防止广告拦截器阻止您的分析数据

token拦截器阻止连接TL;DR Theres dataunlocker.com service coming soon (subscribe!), along with the open-sourced prototype you can use for Google Analytics or Google Tag Manager (2020 update).TL; DR即将推出dataunlocker.com服务 (订阅&#xff01;)&#xff0c;以…

使用Fiddler手机抓包https-----重要

Fiddler不仅可以对手机进行抓包&#xff0c;还可以抓取别的电脑的请求包&#xff0c;今天就想讲一讲使用Fiddler手机抓包&#xff01; 使用Fiddler手机抓包有两个条件&#xff1a; 一&#xff1a;手机连的网络或WiFi必须和电脑&#xff08;使用fiddler&#xff09;连的网络或Wi…

strtok和strtok_r

strtok和strtok_r原型&#xff1a;char *strtok(char *s, char *delim); 功能&#xff1a;分解字符串为一组字符串。s为要分解的字符串&#xff0c;delim为分隔符字符串。 说明&#xff1a;首次调用时&#xff0c;s指向要分解的字符串&#xff0c;之后再次调用要把s设成NULL。 …

iOS 标签自动布局

导入SKTagFrame SKTagFrame *frame [[SKTagFrame alloc] init];frame.tagsArray self.bigModel.Tags;// 添加标签CGFloat first_H 0;CGFloat total_H 0;for (NSInteger i 0; i< self.bigModel.Tags.count; i) {UIButton *tagsBtn [UIButton buttonWithType:UIButtonT…

引导分区 pbr 数据分析_如何在1小时内引导您的分析

引导分区 pbr 数据分析by Tim Abraham蒂姆亚伯拉罕(Tim Abraham) 如何在1小时内引导您的分析 (How to bootstrap your analytics in 1 hour) Even though most startups understand how critical data is to their success, they tend to shy away from analytics — especial…

SSL 1460——最小代价问题

Description 设有一个nm(小于100)的方格&#xff08;如图所示&#xff09;&#xff0c;在方格中去掉某些点&#xff0c;方格中的数字代表距离&#xff08;为小于100的数&#xff0c;如果为0表示去掉的点&#xff09;&#xff0c;试找出一条从A(左上角)到B&#xff08;右下角&am…

在Windows 7下面IIS7的安装和 配置ASP的正确方法

在Windows 7下如何安装IIS7&#xff0c;以及IIS7在安装过程中的一些需要注意的设置&#xff0c;以及在IIS7下配置ASP的正确方法。 一、进入Windows 7的 控制面板&#xff0c;选择左侧的打开或关闭Windows功能 。二、打开后可以看到Windows功能的界面&#xff0c;注意选择的项目…

适配iOS 13 tabbar 标题字体不显示以及返回变蓝色的为问题

// 适配iOS 13 tabbar 标题字体不显示以及返回变蓝色的为问题 if (available(iOS 13.0, *)) {//[[UITabBar appearance] setUnselectedItemTintColor:Color_666666];}

企业不要求工程师资格认证_谁说工程师不能成为企业家?

企业不要求工程师资格认证by Preethi Kasireddy通过Preethi Kasireddy 谁说工程师不能成为企业家&#xff1f; (Who says engineers can’t become entrepreneurs?) A lot of people warned me not to walk away from my great position at Andreessen Horowitz to pursue so…

BestCoder Round #92 比赛记录

上午考完试后看到了晚上的BestCoder比赛,全机房都来参加 感觉压力好大啊QAQ,要被虐了. 7:00 比赛开始了,迅速点进了T1 大呼这好水啊!告诉了同桌怎么看中文题面 然后就开始码码码,4分16秒AC了第一题 7:05 开始看第二题 诶诶诶!!~~~~直接爆搜不久能过吗? 交了一发爆搜上去,AC了,…

[cocos2dx UI] CCLabelAtlas 为什么不显示最后一个字

CClabelAtlas优点&#xff0c;基本用法等我就不说了&#xff0c;这里说一个和美术配合时的一个坑&#xff01;就是图片的最后一位怎么也不显示&#xff0c;如下图中的冒号不会显示 查了ASCII码表&#xff0c;这个冒号的值为58&#xff0c;就是在9&#xff08;57&#xff09;的后…

iOS 13 适配TextField 崩溃问题

iOS 13 之后直接通过以下方式修改Textfield的时候会出现报错信息 [_accountText setValue:Color_666666 forKeyPath:"_placeholderLabel.textColor"]; 报错信息 Access to UITextField’s _placeholderLabel ivar is prohibited. This is an application bug 解决…

测试django_如何像专业人士一样测试Django Signals

测试djangoby Haki Benita通过Haki Benita 如何像专业人士一样测试Django Signals (How to test Django Signals like a pro) For a better reading experience, check out this article on my website.为了获得更好的阅读体验&#xff0c;请在我的网站上查看此文章 。 Djang…

C#中静态方法的运用和字符串的常用方法(seventh day)

又来到了今天的总结时间&#xff0c;由于昨天在云和学院学的知识没有弄懂&#xff0c;今天老师又专门给我们非常详细地讲了一遍&#xff0c;在这里非常谢谢老师。O(∩_∩)O 话不多说&#xff0c;下面就开始为大家总结一下静态方法的运用和字符串的常用方法。 理论&#xff1a;静…

raid 磁盘阵列

mkdir /uuu #建挂载目录echo "- - -" > /sys/class/scsi_host/host2/scan #扫描新硬盘 lsblk #查看 parted /dev/sdb #分区 parted /dev/sdc lsblk mdadm -Cv /dev/md1 -l1 -n2 -c128 /dev/sd[b,c]1 #raid1配置&#xff0c; /dev/md1名字&#…

iOS 13 如何删除SceneDelegate

Xcode11之后新创建的工程会多出两个文件SceneDelegate。那么我们如何让它变回之前的那样的工程呢。 一、将这两个文件删除。 会报错There is no scene delegate set. A scene delegate class must be specified to use a main storyboard file. 二、将Info.plist 中的 SceneMai…

女性程序员大会ghc_在女性科技大会上成为男人的感觉

女性程序员大会ghcby Elijah Valenciano通过伊莱贾瓦伦西亚诺 在女性科技大会上成为男人的感觉 (What It’s Like to be a Man at a Women’s Tech Conference) To be honest, I was very nervous. A few panicked thoughts started to flood my mind as I prepared myself to…

cf776G.Sherlock and the Encrypted Data

题意:对于一个16进制数x,把x的各个数位拿出来,设其为t1,t2,...,定义s(x)为2^t1|2^t2|...,如x0x3e53,则s(x)2^3|2^14|2^5|2^316424.给出q组询问l,r(l,r也是16进制数,不超过15位),求[l,r]中有多少个数x满足x^s(x)<x. 这题题解写的是个状压数位dp,但是蒟蒻不会数位dp,自己YY了一…

c++, 派生类的构造函数和析构函数 , [ 以及operator=不能被继承 or Not的探讨]

说明&#xff1a;文章中关于operator实现的示例&#xff0c;从语法上是对的&#xff0c;但逻辑和习惯上都是错误的。 参见另一篇专门探究operator的文章&#xff1a;《c&#xff0c;operator》http://www.cnblogs.com/mylinux/p/4113266.html 1.构造函数与析构函数不会被继承&a…

json转换模型利器--JSONExport

JSONExport 从json 到 Model &#xff0c;如此的方便 swift oc java 全部支持

亚马逊ses如何发qq_使用Amazon SES发送电子邮件

亚马逊ses如何发qqby Kangze Huang黄康泽 使用Amazon SES发送电子邮件 (Sending emails with Amazon SES) 完整的AWS Web样板-教程3 (The Complete AWS Web Boilerplate — Tutorial 3) 目录 (Table of Contents) Part 0: Introduction to the Complete AWS Web Boilerplate第…

源码-0205-02--聊天布局

还真是失败&#xff0c;搞了两天遇到了布局cell高度总是出差的问题&#xff0c;cell height不是高很多很多&#xff0c;就是就是矮到没有的情况。。。。糟糕透顶待解救&#xff5e; 聊天布局 // // XMGChatingViewController.m // 07-聊天布局 #import "XMGChatingViewC…

js实现页面跳转的几种方式

第一种&#xff1a;<script language"javascript" type"text/javascript"> window.location.href"login.jsp?backurl"window.location.href; </script>第二种&#xff1a; <script language"javascript&q…

Mac 升级系统 pod 命令无效

mac 升级完最新的系统之后 使用pod 命令之后无效报错 -bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory 解决方案 sudo gem install -n /usr/local/bin cocoapods

node seneca_使用Node.js和Seneca编写国际象棋微服务,第1部分

node seneca(This is Part 1 of a three-part series [Part 2, Part 3])(这是一个由三部分组成的系列文章的第1部分[ 第2 部分 &#xff0c; 第3部分 ]) I’ve begun wrapping my head around microservices. Up to this time I regarded it as a scalability pattern and ove…