---
title: "[IOS]NSTimer启动与停止 (2012-02-03 14:49:06)转载"
author: "修博龙泉"
date: "2012-10-18T14:21:38Z"
tags: []
categories: ["移动开发"]
slug: "ios-nstimer-2012-02-03-14-49-06"
draft: false
lastmod: "2012-10-18T14:21:38Z"
id: 1700941
url: "https://longquan.iteye.com/blog/1700941"
---

[IOS]NSTimer启动与停止 (2012-02-03 14:49:06)转载▼
标签： 杂谈	分类： Code
timer =  [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(function:) userInfo:nil repeats:NO];
timer运行一次就会自动停下

timer =  [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(function:) userInfo:nil repeats:YES];
就会每三秒运行一次function

在function:中加入 [timer invalidate];语句可在内部令其停止