美文网首页
iOS知识备忘

iOS知识备忘

作者: LeverTsui | 来源:发表于2019-01-02 15:51 被阅读9次
  • 1、防止编译器警告
// completionBlock在AFURLConnectionOperation中被手动的设置为nil来打破保留周期。
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
    self.completionBlock = ^ {
        ...
    };
#pragma clang diagnostic pop
  • 2、手机系统时间显示佛教或日本日历后,显示时间错误问题
#ifdef __IPHONE_8_0
  NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];//根据Identifer获取公历
#else
  calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];//根据Identifer获取公历
#endif
  calendar.timeZone = [NSTimeZone localTimeZone];//消除时区差异
  calendar.locale = [NSLocale currentLocale];//消除本地化差异,本地化包括语言、表示的日期格式等 
  NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
  formatter.calendar = calendar; 
  • 3、锁的使用
static pthread_mutex_t _sharedDebugLock;
pthread_mutex_lock(&_sharedDebugLock);
...
pthread_mutex_unlock(&_sharedDebugLock);
dispatch_semaphore_t  framesLock = dispatch_semaphore_create(1);
dispatch_semaphore_wait(framesLock, DISPATCH_TIME_FOREVER);
...
dispatch_semaphore_signal(framesLock);
  • 4、循环引用问题
__weak typeof(self) weakSelf = self;
 self.testObject.testCircleBlock = ^{
      __strong typeof (weakSelf) strongSelf = weakSelf;
      [strongSelf doSomething];
}; 

相关文章

  • iOS知识备忘

    1、防止编译器警告 2、手机系统时间显示佛教或日本日历后,显示时间错误问题 3、锁的使用 4、循环引用问题

  • iOS开发学习备忘单

    iOS开发学习备忘单 iOS开发学习备忘单

  • RunLoop 相关

    谨以此篇总结归纳记录iOS中一大知识点 RunLoop 的相关知识,以作备忘。 iOS中,提供了两种runloop...

  • iOS 移动端 安全思考与总结

    iOS 移动端 安全思考 这是一遍安全知识总结的博客,并涉及相关知识的延伸,以作知识备忘和总结。 安全相关的几个方...

  • iOS基础知识备忘

    1、weak关键字的作用 weak的作用是弱引用,它修饰的对象在释放时会置为nil,避免错误的内存访问。一般用于d...

  • iOS 备忘录如何分享到App(Share Extension)

    踩坑记录(检索关键字:怎么分享备忘录,备忘录内容分享到app,iOS 备忘录开发)参考资料: 入门参考资料: 基本...

  • iOS 备忘

  • iOS开发小知识备忘录

    1.设置导航栏透明 2.设置导航栏标题颜色 3.设置状态栏颜色 只要在plist文件里View controlle...

  • iOS开发小知识备忘录

    代码备忘: 1、点击空白处,收起键盘 2、拨打电话 3、web加载网址 4、定时器定义 5、UICollectio...

  • iOS开发小知识备忘录

    代码备忘: 1、点击空白处,收起键盘 2、拨打电话

网友评论

      本文标题:iOS知识备忘

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