I have a tableView controller in my swift app which when loaded, each cell sends a http request to a URL (ex: https://helloworld.com/sendStatus.txt ). say the link displays raw content of status of server (OK or Critical). If ok I turn the cell bg color to Green else Red.
Problem (In Swift) : Each cell is assigned with a diff URL and refresh rate(variable in custom cell object), I would like to set a timer to each cell and change the bg color according to the status returned from the URL.
ex:
How do achieve the timer and refresh for each cell which has different refresh rates.
Please help me with theoretical explanation or sample snippets.
Thanks in advance.
You can create an array (1D if you only have one section) of NSTimer
. Then assign each cell a timer from the array based on their NSIndexPath
in the tableView.cellForRowAtIndexPath
method.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.