zoukankan      html  css  js  c++  java
  • ios 杂记

    1. makeObjectsPerformSelector

    - (void)makeObjectsPerformSelector:(SEL)aSelector;

    - (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)argument;

     

    这是 NSArray和NSSet的两个方法,相信大家很少用,它类似于 for循环,但有效率高于for循环

    makeObjectsPerformSelector:类似于NSNotifation机制,并发的执行同一件事,不能像for循环那样区别对待

    所以参数 argument 必须是非基本类型 ,如果要是用基本类型 请转换程 NSNumber 或者NSValue

     

    [_leavesLayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];

    2. enumerateObjectsUsingBlock

    NSArray *myArray = // 获取数组
    [myArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        if ([(NSString *)obj isEqualToString:@"Cupertino"]) {
            NSLog(@”We’re near the mothership!”);
            *stop = YES;
        }
    }];

    3. UIGestureRecognizer

    http://www.cnblogs.com/pengyingh/articles/2379479.html

    4. dateFromComponents

    为什么dateFromComponents显示日期与实际日期有差别,貌似少了一天?
    是因为没有设置TimeZone,
    [self.calendar setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];

    5. ios根据设备动态加载

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
      //如果是iphone
    }else
    {
      //
    }
    
  • 相关阅读:
    消息路由的构成
    消息的构造
    消息传递通道
    消息传递系统
    EXtJS Ext.data.Model
    oracle coherence介绍及使用
    LINUX下安装和配置WEBLOGIC10.0.3
    WebLogic中"域"的概念
    WebLogic中的一些基本概念
    下属有能力却不服管,你该怎么办?
  • 原文地址:https://www.cnblogs.com/hubj/p/2569552.html
Copyright © 2011-2022 走看看