美文网首页
iOS技巧记录

iOS技巧记录

作者: HenryM | 来源:发表于2015-09-17 14:40 被阅读44次

    使用宏定义根据传入的参数动态生成方法进行调用

     #define Print(func,content) \
    ({ \
                [self Print##func:content]; \
                [self Print##func:content]; \
    })
    - (id)init {
             self = [super init];
               if (self) {
                         Print(B,“hehe”);
                         Print(A,“haha”);
               }
                return self;
    }
    
    - (void)PrintA:(NSString *)content {
    }
    - (void)PrintB:(NSString *)content {
    }
    

    为了能使Xcode能编译C++代码,需要对项目进行配置:Xcode --〉Project --〉Build Settings --〉搜索Compile Sources As ,并将其设置成Objective C++

    Cocoapods引入本地库: pod 'SDURLCache', :path=>‘/Users/janema/Github/SDURLCache/SDURLCache.podspec'
    

    给objc类些hash方法

    如该类有:name,imageName,items三个属性
    那么该类的hash方法可以写成:
    - (NSUInteger)hash {
        return [self.name hash] ^ [self.imageName hash]  ^ [self.items hash];
    }
    该方法借鉴于: https://github.com/goodheart/issue-13-viper/Modules/List/User Interface/Presenter/VTDUpcomingDisplaySection类的hash方法
    

    多Target

    /*
     每增加一个target需要做的配置
     1、targets(XiaoCui50) -> Duplicate
     2、Building Setting
     2、1 :product name
     2、2 :Preprocessor Macros
     3、info.plist
     4、Edit Schema -> Manage Schema
     
     可参考:http://blog.csdn.net/yohunl/article/details/17403029
     */
    

    相关文章

      网友评论

          本文标题:iOS技巧记录

          本文链接:https://www.haomeiwen.com/subject/bnsbcttx.html