顯示具有 Swift 標籤的文章。 顯示所有文章
顯示具有 Swift 標籤的文章。 顯示所有文章

2016年6月22日 星期三

iOS常見面試問題每日研究

本文原自 iOS 中级面试题
http://mrpeak.cn/ios/2016/01/07/push

Day 1. ARC, Automatic Reference Counting

Apple, Transitioning to ARC Release Notes
https://developer.apple.com/library/ios/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html

Wiki, Automatic Reference Counting
https://en.wikipedia.org/wiki/Automatic_Reference_Counting

理解 Objective-C 的 ARC
http://www.oschina.net/translate/objc-automatic-reference-counting-in-xcode-explained

自動引用計數
https://tommy60703.gitbooks.io/swift-language-traditional-chinese/content/chapter2/16_Automatic_Reference_Counting.html

Swifter, @AUTORELEASEPOOL
http://swifter.tips/autoreleasepool/

Day 2. assign vs weak, __block vs __weak

被无数人写过的assign,retain,strong,weak,unsafe_unretained,还有copy
http://www.jianshu.com/p/4a1d1921284b

__weak与__block区别
http://honglu.me/2015/01/06/weak%E4%B8%8Eblock%E5%8C%BA%E5%88%AB/

Day 3. Atomic

Properties Are Atomic by Default
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html

iOS基礎之atomic與nonatomic,assign,copy與retain的定義和區別
http://fanli7.net/a/bianchengyuyan/C__/20130618/372617.html

Objective-C——atomic一定是线程安全的吗?
http://blog.csdn.net/chenyufeng1991/article/details/49687215

Day 4. Retain cycle

Swift 自動引用計數 類別實例之間的迴圈強參考
https://tommy60703.gitbooks.io/swift-language-traditional-chinese/content/chapter2/16_Automatic_Reference_Counting.html#strong_reference_cycles_between_class_instances

iOS blocks - 三個會造成retain cycle的anti patterns
http://popcornylu.blogspot.tw/2012/02/3-anti-patterns-which-lead-memory-leaks.html

Day 5. Runtime

Objective-C Runtime Programming Guide
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Introduction/Introduction.html

iOS runtime学习笔记
http://www.jianshu.com/p/970ae3bac1ef

理解 Objective-C Runtime
http://justinyan.me/post/1624

Day 6. +(void)load; +(void)initialize;

Objective C类方法load和initialize的区别
http://www.cnblogs.com/ider/archive/2012/09/29/objective_c_load_vs_initialize.html

Day 7. Method swizzling

Objective-C的hook方案(一): Method Swizzling
http://blog.csdn.net/yiyaaixuexi/article/details/9374411

Objective-C Runtime 运行时之四:Method Swizzling
http://southpeak.github.io/blog/2014/11/06/objective-c-runtime-yun-xing-shi-zhi-si-:method-swizzling/

Day 8. UIView與CALayer

详解 CALayer 和 UIView 的区别和联系
http://www.cocoachina.com/ios/20150828/13244.html

KKBOX iOS/Mac OS X 基本開發教材 CALayer
https://zonble.gitbooks.io/kkbox-ios-dev/content/core_animation/calayer.html

Day 9. UIImageView 圓角

iOS 高效添加圆角效果实战讲解
http://www.jianshu.com/p/f970872fdc22

Day 10. drawRect

iOS重绘机制drawRect
http://blog.csdn.net/nyh1006/article/details/38899251

内存恶鬼drawRect
http://bihongbo.com/2016/01/03/memoryGhostdrawRect/

Day 11. 研究Alamofire

GitHub Alamofire/Alamofire
https://github.com/Alamofire/Alamofire

对于AlamoFire几点思考,AlamoFire几点思考
http://www.zendei.com/article/4319.html

Alamofire 源码赏析(一)基础篇
http://liuduo.me/2015/11/17/Alamofire-%E6%BA%90%E7%A0%81%E8%B5%8F%E6%9E%90%EF%BC%88%E4%B8%80%EF%BC%89%E5%9F%BA%E7%A1%80%E7%AF%87/

优秀源码阅读:Swift网络库Alamofire
http://www.cocoachina.com/ios/20151118/14240.html

从 Alamofire 源码学习 Swift
http://broccoliii.me/2016/05/07/Learning_Swift_from_Alamofire_source/

Day 12. Instrument

Instruments Tutorial with Swift: Getting Started
https://www.raywenderlich.com/97886/instruments-tutorial-with-swift-getting-started

Day . GCD

KKBOX GCD(Grand Central Dispatch)
https://zonble.gitbooks.io/kkbox-ios-dev/content/threading/gcd.html

2015年5月10日 星期日

iOS學習資源彙整

Swift 入門:

The Swift Programming Language
(蘋果的官方教學 英文版 把前兩章讀完就能大致了解Swift了)
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097-CH3-ID0

《正體中文版蘋果 Swift 官方教學》
(The Swift Programming Language 的中文版)
http://tommy60703.gitbooks.io/swift-language-traditional-chinese/content/

玩儿转Swift:
(大陸的mooc教學 有豐富講解)
http://www.imooc.com/learn/127

Swifter - Swift 必备 tips:
(每個禮拜三更新的進階Swift)
http://swifter.tips/

Swift iOS:

使用Swift开发iOS8 App实战
(首推這個教程 相當適合入門)
http://www.imooc.com/learn/173

iOS With Girlfriend
(非常入門好懂 一二章節還有提到Sketch設計的部分)
https://youtu.be/LEQpV9znZsk?list=PLdxID9MLTgg-oHgbxcBGtPrgkrvucDOnB

愛瘋一切為蘋果的彼得潘
(Swift書籍的作者 每天發布iOS的好文章)
https://www.facebook.com/iphone.peterpan/?fref=ts

Stanford - Developing iOS 8 Apps with Swift [2015]
(Stanford大學的課程影片)
https://www.youtube.com/playlist?list=PLy7oRd3ashWodnpf8rjfYEkTgwbOEsKfU

// 這邊Swift資源還滿多的
// 以下可以有空再看看 比較進階一點

KKBOX iOS/Mac OS X 基礎開發教材
(進階的iOS教材 建議有一定基礎與OC概念再讀)
https://zonble.gitbooks.io/kkbox-ios-dev/content/

Swift Weather APP
(Swift的進階課程 有用到第三方管理套件CocoaPods)
http://www.imooc.com/learn/149

iOS Human Interface Guidelines
(iOS人機介面指南 這好像有中文版 需要可以找找看)
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/

App Programming Guide for iOS
https://developer.apple.com/library/prerelease/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007072

imooc iOS類別
(慕課網有相當多iOS教學 自行去挖寶吧!)
http://www.imooc.com/course/list?c=ios

一起来做价值百万的Apple Watch App:分歧终端机
(Apple Watch的Swift課程)
http://www.imooc.com/view/242

Let's Swift
(各種Swift應用文章)
http://letsswift.com/

Objective-C:

Objective-C Tutorial
(雖然某些資料偏舊 不過也是個不錯的學習地點)
http://www.tutorialspoint.com/objective_c/

征战Objective-C:
(幕課網的OC入門教學)
http://www.imooc.com/learn/218

Objective-C面向对象初体验:
(OC物件導向的教學)
http://www.imooc.com/learn/373

imooc iOS類別
(慕課網也有很多OC的教學哦)
http://www.imooc.com/course/list?c=ios

2015年1月19日 星期一

Swift eunm fromRaw() and toRaw() in Xcode 6.1

首先我們先建立一個Rank的列舉 大致如下
我們可以看到Ace = 1 有趣的是
就算我們沒有給Two, Three...值 他也會遞增給予值
所以Two = 2, Three = 3
到最後的Jack = 11, King = 13

要注意的是 在Xcode 6.1當中
已經沒有fromRaw()這個方法了
改為列舉的屬性rawValue
在這邊我們宣告一個常數ace取得Rank中ace的列舉值
ace再轉換成rawValue就可以看到原先的整數值:1

toRaw()這個方法也被替換掉了
取而代之的是以下的寫法
我把raw為1的列舉值記在rawAce當中
你可以看到 他跟ace是相同的列舉值

大家也可以看看stackoverflow 這邊也有人在討論
看看第3個回應 解說得還不錯
http://stackoverflow.com/questions/26444107/enums-rawvalue-property-not-recognized