zoukankan      html  css  js  c++  java
  • timer

    Objective-C Timer(实用)

     (2011-04-07 10:38:51)
    标签: 

    ipad

     

    iphone

     

    ios

     

    it

     

    objective-c

     

    开发

     

    移动

    分类: iPhone


    //I am creating a dictionary object that I can pass to my selector method.


    NSArray *keys = [NSArray arrayWithObjects:@"key1"@"key2"@"key3"nil];


    NSArray *objects = [NSArray arrayWithObjects:@"value1"@"value2"@"value3"nil];


    NSDictionary *myDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];


    [NSTimer scheduledTimerWithTimeInterval:1.0 target:selfselector:@selector(fireTimer:) userInfo:myDictionary repeats:YES];


    //The fireTimer() is the selector method I setup above


    - (void) fireTimer:(NSTimer*)theTimer {

    for (id key in [theTimer userInfo]) {

    NSLog(@"key: %@, value: %@", key, [[theTimer userInfoobjectForKey:key]);

    }

    //kill the timer

    [theTimer invalidate];

    theTimer = nil;

    }


     


    //here is a similar example but with using an NSNumber


    NSNumber *myInt = [NSNumber numberWithInt:4];


    [NSTimer scheduledTimerWithTimeInterval:1.0 target:selfselector:@selector(fireTimer:) userInfo:myInt repeats:YES];


    - (void) fireTimer:(NSTimer*)theTimer {

    NSLog(@" %i ", [[theTimer userInfo] integerValue]);

    [theTimer invalidate];

    theTimer = nil;

    }

  • 相关阅读:
    opencv+python实时人脸检测、磨皮
    opencv人脸检测
    均值模糊、中值模糊、自定义模糊
    双边滤波
    表面模糊
    水纹滤镜
    爬取https网站
    字符串、数组、切片、map
    tcpdump抓包和Wireshark解包
    iptables详解
  • 原文地址:https://www.cnblogs.com/moonvan/p/2248521.html
Copyright © 2011-2022 走看看