Objective-C 运行时对于刚刚踏入 Cocoa/Objective 世界的人是很容易忽
略的 Objective-C 语言的特性之一。原因就是尽管 Objective-C 是一门几个小时之内入门的语言,但是投身 Cocoa 的新手们会花费大量时间在 Cocoa 框架中,试图搞清楚他到底是怎么工作的。 我觉得每个开发者都应该对其有深入的了解,明白一些内部的实现细节,而不仅仅只知道代码 [target doMethodWith:var] 会被编译器转换成 objc_msgSend(target,@selector(doMethodWith:),var1); 而已。了解 Objective-C 运行时的原理有助于你对 Objective-C 语言有更深入的理解,清楚你得 App 是怎么运行的。我觉得这对无论是 Mac/iPhone 新手或者老手都会有所帮助。
理解Objective-C运行时
我们是如何创建iOS版的Guillotine菜单动画的
原文:How We Created Guillotine Menu Animation for iOS 原作者 @johnsundell
你是否曾经有过这样的疑问?为什么app中几乎是清一色的侧边栏(sidebar),为什么不把它做成topBar或者bottomBar,甚至cornerBar呢?
[28] Implement strStr()
题目:28. Implement strStr()
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
题意:
该题目就是实现strstr()函数,该函数C语言原型如下:返回字符串str1在str2中的位置。
[257] Binary Tree Paths
题目:257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths.
For example, given the following binary tree:
1
/
2 3
5
All root-to-leaf paths are:
[“1->2->5”, “1->3”]
题意:
难度不大,考察树的遍历
解法:
C++版本实现方法:
|
|
[018] Length Of Last Word
题目:
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defined as a character sequence consists of non-space characters only. For example, Given s = “Hello World”, return 5.
题意:
难度不大,考虑所有边界情况即可。