上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页

2018年1月7日

摘要: 条件变量是一种同步机制,允许线程挂起,直到共享数据上的某些条件得到满足。条件变量上的基本操作有:触发条件(当条件变为 true 时);等待条件,挂起线程直到其他线程触发条件 while ()为什么是while而不是if?因为可能会有虚假唤醒的问题。 "This means that when you wait on a condition variable, the wait may (o... 阅读全文
posted @ 2018-01-07 10:41 花老🐯 阅读(244) 评论(0) 推荐(0) 编辑

2018年1月4日

摘要: “undefined behavior: behavior for which this International Standard imposes no requirements.” example of Undefined BehaviorUse of an uninitialized variableMisaligned pointers Access to an object... 阅读全文
posted @ 2018-01-04 07:42 花老🐯 阅读(541) 评论(0) 推荐(0) 编辑
摘要: 要用 release 版本来profile 概述time profile 是使用采样的方法来统计,而不是记录每一个方法调用的起始和结束,采样间隔是 1 ms。 在上图中,main 函数被采样了 5 次, method3 没有被采样,但是确实执行了。不能区分长时间运行的任务和重复执行的任务。关注点是 CPU,而且不会记录所有操作。比如 method3 没有被采样。 如何看 time profi... 阅读全文
posted @ 2018-01-04 07:41 花老🐯 阅读(915) 评论(0) 推荐(0) 编辑

2018年1月3日

摘要: 原理使用 system trace 时,会记录最近 5s 的 kernel trace,然后分析下面的操作: Scheduling activity System calls Virtual memory operations使用在代码里插入相应的语句,当运行到这里是,会在 Instrument 的结果中。插入的语句可以指明一个事件的发生,或者一个时间段的起始和结束。其中第一个参数指定事件的 ... 阅读全文
posted @ 2018-01-03 21:04 花老🐯 阅读(1090) 评论(0) 推荐(0) 编辑

2017年12月30日

摘要: 在内存管理方面容易有缺失。无法确定将要执行的选择子具体是什么,所以 ARC 无法插入适当的内存管理方法选择子的返回类型只能是 id,最多有两个参数。所以尽量避免使用这个东西。 下面来自苹果的文档Different messages require different memory management strategies for their returned objects, and it m... 阅读全文
posted @ 2017-12-30 11:12 花老🐯 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 相较于 NSDictionary 线程安全系统资源将要耗尽时,自动删减缓存自动删减“最久未使用的”对象不会自动拷贝键。因为有些键不支持拷贝操作可以和 NSPurgeableData 联合使用 阅读全文
posted @ 2017-12-30 08:31 花老🐯 阅读(179) 评论(0) 推荐(0) 编辑

2017年12月28日

摘要: performSelector 指定的方法没有被调用Invokes a method of the receiver on the current thread using the default mode after a delay.根据苹果的文档,performSelector:withObject:afterDelay: 在指定时间之后,在当前线程 调用一个方法。如果这个线程在指定时间之后... 阅读全文
posted @ 2017-12-28 22:42 花老🐯 阅读(267) 评论(0) 推荐(0) 编辑

2017年12月27日

摘要: 在 OC 中,类的一个实例定义如下: /// Represents an instance of a class.struct objc_object { Class _Nonnull isa OBJC_ISA_AVAILABILITY;};即每一个对象,都有一个 isa 指针,指向它的 CLASS。而 CLASS 定义如下: /// An opaque type that repre... 阅读全文
posted @ 2017-12-27 22:31 花老🐯 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 原理类的方法类别中,选择子的名称通过映射表找到应该调用的方法。如下所示:OC 的运行时提供了几个方法可以操作这张表。可以向其中新增选择子,改变选择子的实现,或者交换选择子映射到的指针。在上图中,交换了 lowercaseString 和 uppercaseString 方法实现,新增了一个选择子 newSelector,修改了 capitalizedString 的实现。 方法交换实现 De... 阅读全文
posted @ 2017-12-27 21:40 花老🐯 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 问题有一个 1000 个 cell 的 tableView,刚刚进入界面时,contentOffset 为 0。用手快速滑动 tableView,直至最下面一个 cell 显示在屏幕上。这个过程中,cellForRow 被调用了几次呢? 手写 demo新建一个工程,只有一个 tableView,然后从上滚到下。在 cellForRowAtIndexPath方法中把 row 加到数组中,然后滚动停... 阅读全文
posted @ 2017-12-27 19:12 花老🐯 阅读(416) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 30 下一页

导航