具体描述
Fake Books are an indispensable tool for jazz musicians. They contain the melody, rhythm, and chord changes for hundreds of standards, allowing a player to jump into any session cold, and "fake it" through any tunes outside their repertoire. It's not sheet music, but rather the essence of tunes.
Cm11 B9 B♭m9 A♭13 G13 and trade fours with the tenor...
Programmers aren't all that different. Once you get the fundamentals down, it's really just about memorizing the APIs. Sure, you could read the docs, but nothing compares to the excitement of tinkering with code.
That's the idea behind The NSHipster Fake Book: expanding your repertoire through concise code samples, with minimal explanation. It's about letting concepts click as you discover new licks you'd never thought to try. Just pick it up and start playing—no matter what kind of chops you have.
In this book, you'll find over 200 code samples, ranging from the beginner and basic to the expert and obscure, across a variety of genres and use cases.
(And for those of you wondering, there are no plans for a print edition of The NSHipster Fake Book. Instead, in the tradition of the medium, feel free to print it out at home. Bonus points for Comb Binding)
作者简介
目录信息
Creating a Nonretained Object Value
Adding an Anonymous Observer to a Notification Center
Accessing Thread-Unsafe Objects from a Thread Dictionary
Converting a String to a Number
Converting a Number to a String
Implementing Indexed Subscripting
Implementing Keyed Subscripting
Using a Method that accepts an Error Parameter
Implementing a Method that takes an Error Parameter
Logging Class, Method, and Line Number Context
Key-Value Archiving & Unarchiving an Object
Archiving / Unarchiving an Object into NSUserDefaults
Creating a KeyPath from Selector
Adding an Item to the Keychain
Evaluating a Mathematical Expression
Decoding JSON
Encoding JSON
Getting the Name of the Device
Language & Runtime
Declaring an NS_ENUM Type
Declaring an NS_OPTIONS Type
Creating String Representations for Enumerated Type
Adding a Property to a Category
Swizzling a Method
Determining the Type of a Property
Determining the Type of a CFTypeRef
Specifying the Availability of a Method
Hiding a Class
Hiding a Method
Ignoring Compiler Warnings
Determining the Current System Memory Usage
Getting the Current OS Version
Declaring a Constant Value
Determining Whether an Object is Null
Declaring an Argument or Parameter as Unused
Creating Variadic Method
Creating a Variadic Function
Overloading Functions
Determining if ARC is Available
Conditionally Compiling for iOS & OS X Targets
Determining if Class is Available for Target Platform at Runtime
Determining if Method is Available for Target Platform at Runtime
Determining if Function is Available for Target Platform at Runtime
Adding a Class at Runtime
Adding a Method to a Class at Runtime
Getting the Subclasses and Superclasses of a Class
Requiring Method to call super
Determining the Caller of a Method
Creating Variadic Formatting Method
Intentionally Crashing the Current Process
Grand Central Dispatch
Dispatching Work Asynchronously to a Background Queue
Benchmarking the Execution Time of an operation
Monitoring Local File Changes
Creating a Singleton
Monitoring the Parent Process PID
Reading from STDIN
Monitoring Local File Changes
Dispatching a Timer
Cryptography
Encrypting & Decrypting Using AES-128 With PBKDF2 Key
Base64-Decoding Data
Base64-Encoding Data
Calculating MD5 Digest
Calculating SHA-1 Digest
Generating SHA-1 HMAC
Random
Creating a Random Integer
Creating a Random Double
Creating a Random String
Creating a Random Date
Generating Random Bytes
Creating a UUID
Creating a GUID
Collections
Enumerating an Array
Enumerating a Dictionary
Creating a Mutable Copy of an Array
Creating a Mutable Copy of a Dictionary
Creating a Case-Insensitive Dictionary
Accessing Mutable Dictionary in a Thread-Safe Manner
Reversing an Array
Shuffling an Array
Creating a String from an Array
Filtering Objects in Array by Class
Computing the Sum of an Array
Removing Duplicate Objects from an Array
Linguistics & Typography
Creating a Font from TTF / OTF Data
Determining the Current Language
Looking Up the Definition of a Word
Applying Foreground Color to an Attributed String
Creating an Attributed String from HTML
Getting Characters from a Character Set
Detecting Phone Number and Address from a String
Comparing Version Numbers
Finding Proper Nouns in a String
Calculating String Entropy
Formatting Strings
Determining the Language of a String
Concatenating String Literals
Determine if a String Contains Punctuation
Splitting a String into an Array
Determining if a String Contains a Particular Substring
Tokenizing a String
Squashing Whitespace in a String
Stripping Whitespace from a String
Getting the Small Caps Variant of a Font
Responding to Changes in a Text Field
Determining if a String is Empty
Determining if an Array is Empty
Determining if a Dictionary is Empty
Date & Time
Extracting Components from a Date
Creating a Date from Components
Performing Calendar Arithmetic
Parsing & Formatting an ISO 8601 timestamp
Parsing & Formatting an RFC 3339 Timestamp
Determining if Device is Set for 24 Hour Time
Filesystem
Finding Application Support Directory
Finding Caches Directory
Listing all files in a directory
Creating a Directory
Recursively Enumerating all files in a directory
Finding Documents Directory
Finding Downloads Directory
Determining the Creation Date of a File
Deleting a File
Determining if a File Exists
Finding Library Directory
Writing a String to Disk
Sorting Files by Filename
Setting Extended File Attributes
Cartography
Getting Directions Between Two Locations
Formatting a Localized Distance String
Searching for a Geographic Location
Creating Map Snapshots of Waypoints
Rendering Annotations on a Map View
Fitting a Map View to Annotations
Rendering Overlays on an MKMapView
Localizing Address Format of a Placemark
Describing a Placemark for a Coordinate Region
Creating a Custom Map Tile Overlay
Converting Degrees to Radians
Converting Radians to Degrees
Convert Radians to CLLocationDirection
Graphics
Animating a CAGradientLayer
Splitting a CGRect
Ensuring that a CGRect is not on a Pixel Boundary
Generating a QR Code
Reading a QR Code
Creating an Image for a Swatch of Color
Cropping an Image to Face
Detecting a Face in an Image
Resizing an Image
Converting an Image to Data
Determining the File Type of Image
Applying a CIFilter on an Image
Rounding Corners of a View
Getting Color RGB Components
Lightening / Darkening a Color
Creating a Color from Hexadecimal String
Inverting a Color
Networking
Making a Request with CFNetwork
Creating a Bound NSStream Pair
Constructing an HTTP User-Agent
Determining the MIME Type for a File Extension
Setting HTTP Headers for a URL Request
Escaping URLs
Building a URL relative to a Base URL
Setting the Shared URL Cache
Making Asynchronous Network Request with NSURLConnection
Making Synchronous Network Request with NSURLConnection
Making Asynchronous Network Request with NSURLSession
Getting List of Network Interfaces
Monitoring Network Reachability
Validating an SSL Certificate
Adding a URL to the Safari Reading List
UIKit
Determining the Current Device Model
Forcing Screen Orientation
Making a Device Vibrate
Implementing UITableViewDataSource
Implementing UITableViewDelegate
Using iOS 6 Styles for Standard Controls in iOS 7 App
Creating a Snapshot of a View
Determining if UIViewController is Visible
Removing Bounce from UIWebView
Removing Drop Shadow from UIWebView
Preventing Links from Being Tapped in UIWebView
· · · · · · (收起)
读后感
用户评价
坦白说,我对Objective-C的感情是复杂的,它既是我的“第一门语言”,也是很多现代化开发中被视为“遗留”的技术栈。因此,我希望这本书能填补现代开发者在回顾历史代码时产生的知识断层。我不在乎它会不会教我最新的Swift语法,我更想知道,在那个时代,顶尖的工程师们是如何用Objective-C的“怪癖”来实现令人称奇的功能的。例如,KVC/KVO的底层实现机制,`category`的运行时加载过程,以及如何巧妙地利用`selector`进行方法交换来进行AOP(面向切面编程)。这些技巧是理解很多底层框架和第三方库工作原理的基石。如果这本书能够揭示一些Apple内部API设计哲学背后的故事,那无疑会提升这本书的价值,使其从一本技术参考书升华为一部行业历史见证录。我希望它能让我重拾对这门语言的热情,而不是仅仅将其视为一个维护旧代码的工具。
这本书的封面设计得很有意思,色彩搭配和字体选择都透露出一种复古又专业的味道,让人忍不住想翻开看看里面到底藏着些什么“黑科技”。我一直对Objective-C这种经典语言抱有敬畏之情,市面上很多新的技术书籍都把重点放在Swift上,所以能找到一本专门针对Objective-C深入剖析的书籍,实在难得。从目录上看,它似乎涵盖了从基础语法到高级特性,再到一些实际开发中的疑难杂症的解决方案。我尤其期待看到作者如何解读内存管理中的那些“灰色地带”,毕竟ARC的出现并没有完全消除所有关于指针和生命周期的困惑。如果这本书能提供一些作者多年实践中总结出来的、未经官方文档过度美化的“野路子”或者性能优化的独家秘笈,那绝对是物超所值了。这本书的定位似乎是面向有一定基础的开发者,那些渴望从“会用”进阶到“精通”的人,希望它能真正做到深入浅出,而不是仅仅停留在API的罗列上,那样的话,任何官方文档都能替代了。我希望读完后,能对Objective-C的运行时机制有一个全新的、更深刻的理解,能够自信地去调试那些看似无法解释的崩溃和内存泄漏问题。
作为一名对代码整洁度和可维护性有高要求的开发者,我非常看重技术书籍中对“最佳实践”的阐述。对于Objective-C这种动态性极强的语言,代码风格和设计模式的应用尤为重要,否则项目很快就会变成一个难以维护的“意大利面条式”代码库。我希望这本书不仅仅停留在“如何实现功能”,更应该深入探讨“如何优雅地实现功能”。比如,如何有效地组织类之间的职责划分,如何在不引入过多复杂性的前提下利用Objective-C的特性实现解耦,以及对设计模式(如MVC、MVVM在Objective-C环境下的具体落地)的批判性分析。我尤其期待看到作者对那些被过度使用的“设计模式”提出独到的见解,甚至是如何反模式(Anti-pattern)的识别与规避。如果书中能提供一套成熟的、经过实战检验的代码审查清单(Checklist),这将是对提升团队代码质量的巨大帮助。一本真正优秀的指南,应该能帮助我们写出不仅能运行,而且能在未来数年内仍能被轻松理解和修改的代码。
我对技术书籍的阅读习惯比较挑剔,通常我会先快速浏览一下作者的背景和这本书的写作意图。这本书的标题非常大胆且引人注目,带有强烈的个人风格,这让人对其内容的独特性抱有很高的期望。我希望它不仅仅是一本标准的教科书,而是能像一位经验丰富的老兵在手把手地教导新兵如何在战场上生存下来。市面上充斥着太多那种平铺直叙、缺乏“灵魂”的技术手册,而一本好的技术书应该能激发读者的好奇心,并提供解决实际问题的“思维框架”。我关注的是它对Cocoa框架底层机制的阐述是否到位,比如`runloop`是如何驱动事件响应的,`view`的绘制流程究竟在系统层面是如何被高效管理的。如果作者能结合一些经典开源项目的源码来剖析这些机制,那就更棒了。此外,如果书中包含一些关于如何进行跨版本兼容性处理的经验分享,对于那些维护老旧项目的人来说,简直就是雪中送炭。这本书如果能提供一种不同于主流教程的视角来看待Objective-C的生命周期,那它就成功了。
拿到这本书时,首先吸引我的是它的排版和图表质量。清晰的流程图和代码示例的格式化是衡量一本技术书是否专业的关键指标之一。我特别关注那些关于并发编程和多线程处理的部分。在Objective-C时代,GCD和NSOperationQueue是处理复杂任务的核心工具,但真正掌握它们的精髓,尤其是在处理竞态条件和死锁问题时,往往需要大量的实践和深刻的理论支撑。我期望这本书能用非常直观的方式,解析操作队列的依赖关系、GCD的内存陷阱,以及如何利用`dispatch_semaphore`等工具进行精确的资源控制。很多教程对这些高级概念往往一笔带过,留给读者的只有困惑。如果这本书能提供一套系统性的、可复用的并发设计模式,那就太棒了。毕竟,在移动应用的性能瓶颈中,UI卡顿和不稳定的后台处理往往是重灾区,而这直接与并发处理的质量挂钩。我非常期待看到作者如何用Objective-C的语法特性来优雅地解决这些棘手问题。
Code snippets 可以
Code snippets 可以
Code snippets 可以
Code snippets 可以
Code snippets 可以