ios developer tiny share
zheng3stone
每天积累一点点
展开
-
ios developer tiny share-20160831
今天讲Objective-C的点语法,它是accessor方法的简写形式。Dot Syntax Is a Concise Alternative to Accessor Method CallsAs well as making explicit accessor method calls, Objective-C offers an alternative dot syntax to原创 2016-09-02 18:27:59 · 220 阅读 · 0 评论 -
ios developer tiny share-20160914
今天讲unsafe_unretained以及__unsafe_unretained的关键词使用方法。Use Unsafe Unretained References for Some ClassesThere are a few classes in Cocoa and Cocoa Touch that don’t yet support weak references, whic原创 2016-09-21 18:12:47 · 170 阅读 · 0 评论 -
ios developer tiny share-20160915
今天讲copy关键字的用法,可以使属性不被改变。Copy Properties Maintain Their Own CopiesIn some circumstances, an object may wish to keep its own copy of any objects that are set for its properties.As an example原创 2016-09-21 18:29:09 · 210 阅读 · 0 评论 -
ios developer tiny share-20160929
今天讲Objective-C的protocol的继承。Protocols Inherit from Other ProtocolsIn the same way that an Objective-C class can inherit from a superclass, you can also specify that one protocol conforms to ano原创 2016-10-11 10:45:52 · 152 阅读 · 0 评论 -
ios developer tiny share-20160930
今天讲Objective-C的“Conforming to Protocols”话题。Conforming to ProtocolsThe syntax to indicate that a class adopts a protocol again uses angle brackets, like this@interface MyClass : NSObject原创 2016-10-11 15:53:09 · 208 阅读 · 0 评论 -
ios developer tiny share-20161008
今天讲Cocoa and Cocoa Touch Define a Large Number of Protocols。Cocoa and Cocoa Touch Define a Large Number of ProtocolsProtocols are used by Cocoa and Cocoa Touch objects for a variety of diffe原创 2016-10-12 14:04:59 · 186 阅读 · 0 评论 -
ios developer tiny share-20161009
今天讲Objective-C使用protocol隐藏实现。Protocols Are Used for AnonymityProtocols are also useful in situations where the class of an object isn’t known, or needs to stay hidden.As an example, the原创 2016-10-13 16:15:01 · 79 阅读 · 0 评论 -
ios developer tiny share-20161024
今天讲Objective-C的Set,无序不可以重复的集合。Sets Are Unordered CollectionsAn NSSet is similar to an array, but maintains an unordered group of distinct objects, as shown in Figure 6-2.Figure 6-2 A Set原创 2016-11-04 13:01:21 · 175 阅读 · 0 评论 -
ios developer tiny share-20161014
今天讲ios的NSNumber,以及NSUIntegerNumbers Are Represented by Instances of the NSNumber ClassThe NSNumber class is used to represent any of the basic C scalar types, including char, double, float, in原创 2016-10-24 19:06:33 · 157 阅读 · 0 评论 -
ios developer tiny share-20161025
今天讲Objective-C的字典NSDictionary。Dictionaries Collect Key-Value PairsRather than simply maintaining an ordered or unordered collection of objects, an NSDictionary stores objects against given key原创 2016-11-04 19:19:55 · 170 阅读 · 0 评论 -
ios developer tiny share-20160908
今天讲下Objective-C的属性的原子性,即Atomic相关的,以及涉及的同步问题。Properties Are Atomic by DefaultBy default, an Objective-C property is atomic:@interface XYZObject : NSObject@property NSObject *implicitAtomicOb原创 2016-09-08 16:27:01 · 153 阅读 · 0 评论 -
ios developer tiny share-20160928
今天讲Objective-C的protocol的两个知识点,分别是带可选方法的协议,以及在运行时时检查可选方法是否实现。Protocols Can Have Optional MethodsBy default, all methods declared in a protocol are required methods. This means that any class th原创 2016-10-10 15:18:52 · 243 阅读 · 0 评论 -
ios developer tiny share-20160907
今天讲自定义Accessor方法,除了前面讲的Objective-C会自动生成getter、setter的Accessor方法,你也可以自定义getter、setter方法。You Can Implement Custom Accessor MethodsProperties don’t always have to be backed by their own instance vari原创 2016-09-08 10:24:34 · 171 阅读 · 0 评论 -
ios developer tiny share-20160901
今天讲Objective-C的synthesized,以及下划线的用法。Most Properties Are Backed by Instance VariablesBy default, a readwrite property will be backed by an instance variable, which will again be synthesized automat原创 2016-09-03 11:18:17 · 216 阅读 · 0 评论 -
ios developer tiny share-20160824
前面几节,我们讲了创建对象的方法,包括alloc、init、initWithXX、工厂方法,今天我们讲使用new来创建对象,另外,会讲试用“@”来创建literal类型的对象。Use new to Create an Object If No Arguments Are Needed for InitializationIt’s also possible to create an ins原创 2016-08-25 18:44:32 · 189 阅读 · 0 评论 -
ios developer tiny share-20160902
今天接着昨天的,讲@Synthesized。另外,会讲没有@property的实例变量。You Can Customize Synthesized Instance Variable NamesAs mentioned earlier, the default behavior for a writeable property is to use an instance variabl原创 2016-09-05 15:28:52 · 166 阅读 · 0 评论 -
ios developer tiny share-20160905
今天讲Objective-C在类的继承情况下的初始化顺序。Access Instance Variables Directly from Initializer MethodsSetter methods can have additional side-effects. They may trigger KVC notifications, or perform further task原创 2016-09-05 15:55:54 · 158 阅读 · 0 评论 -
ios developer tiny share-20160906
今天讲下Objective-C的类存在多个初始化的方法时,互相调用以及调用父类的初始化方法的情况。The Designated Initializer is the Primary Initialization MethodIf an object declares one or more initialization methods, you should decide which原创 2016-09-06 17:26:26 · 268 阅读 · 0 评论 -
ios developer tiny share-20160913
今天讲下Objective-C使用弱引用的场景,以及注意的要点。Use Strong and Weak Declarations to Manage OwnershipBy default, object properties declared like this:@property id delegate;use strong references for their syn原创 2016-09-19 13:16:13 · 200 阅读 · 0 评论 -
ios developer tiny share-20160926
本节开始,我们将讲Objective-C的面向接口编程,先看下本章的OverView。Working with ProtocolsIn the real world, people on official business are often required to follow strict procedures when dealing with certain situa原创 2016-10-09 13:51:27 · 166 阅读 · 0 评论 -
ios developer tiny share-20160927
今天继续讲Objective-C的protocol,讲“Protocols Define Messaging Contracts”。Protocols Define Messaging ContractsA class interface declares the methods and properties associated with that class. A prot原创 2016-10-09 16:56:21 · 168 阅读 · 0 评论 -
ios developer tiny share-20160916
今天开始新的一章,讲objective-c的类的扩展,通过继承现有类来扩展类的功能。先看下overview的介绍。Customizing Existing ClassesObjects should have clearly-defined tasks, such as modeling specific information, displaying visual conte原创 2016-09-23 17:00:42 · 178 阅读 · 0 评论 -
ios developer tiny share-20161010
今天讲Objective-C的整型类和集合类。Values and CollectionsAlthough Objective-C is an object-oriented programming language, it is a superset of C, which means you can use any of the standard C scalar (non-o原创 2016-10-14 13:46:53 · 233 阅读 · 0 评论 -
ios developer tiny share-20160919
本节讲Objective-C中使用category,来给现有类增加新的方法。Categories Add Methods to Existing ClassesIf you need to add a method to an existing class, perhaps to add functionality to make it easier to do somethi原创 2016-09-29 15:54:36 · 170 阅读 · 0 评论 -
ios developer tiny share-20160920
今天讲category方法的名称冲突以及解决办法Avoid Category Method Name ClashesBecause the methods declared in a category are added to an existing class, you need to be very careful about method names.If the n原创 2016-09-29 16:57:12 · 218 阅读 · 0 评论 -
ios developer tiny share-20161013
今天讲Objective-C的基本类型对应的对象封装类型Objects Can Represent Primitive ValuesIf you need to represent a scalar value as an object, such as when working with the collection classes described in the next原创 2016-10-20 18:40:15 · 174 阅读 · 0 评论 -
ios developer tiny share-20161019
今天讲Objective-C的Collection的Array。Arrays Are Ordered CollectionsAn NSArray is used to represent an ordered collection of objects. The only requirement is that each item is an Objective-C objec原创 2016-10-27 15:45:20 · 163 阅读 · 0 评论 -
ios developer tiny share-20161102
今天讲Objective-C中带参数和返回值的Block。下面是ios reference官方的讲解:Blocks Take Arguments and Return ValuesBlocks can also take arguments and return values just like methods and functions.As an e原创 2016-11-16 13:35:08 · 166 阅读 · 0 评论 -
ios developer tiny share-20161020
本节讲Objective-C数组的遍历和排序Querying Array ObjectsOnce you’ve created an array, you can query it for information like the number of objects, or whether it contains a given item:NSUInteger numb原创 2016-11-01 22:31:23 · 148 阅读 · 0 评论 -
ios developer tiny share-20161021
今天讲Objective-C的可变数组,之前讲的NSArray是不可变的,immutable,今天讲NSMutableArray,它是可变的。MutabilityAlthough the NSArray class itself is immutable, this has no bearing on any collected objects. If you add a mu原创 2016-11-02 13:32:22 · 192 阅读 · 0 评论 -
ios developer tiny share-20161103
今天继续讲Objective-C的Block,讲Block可以访问外部的变量,但是它不可以改变外部变量,实际上,它访问的是该变量的一个常量类型的值,该值之后的改变也无法跟踪。下面是ios reference官方的讲解:Blocks Can Capture Values from the Enclosing ScopeAs well as containing e原创 2016-11-17 17:30:12 · 214 阅读 · 0 评论 -
ios developer tiny share-20161104
今天继续讲Objective-C的Block,上一节讲过,在作用域内,一般是一个方法体内,Block不可以修改外部的变量的值。这一节我们讲如何实现可以在Block内修改外部的变量,即使用__block修饰符修饰该变量。下面是android developer官方文档的讲解:Use __block Variables to Share StorageIf you原创 2016-11-18 15:04:45 · 184 阅读 · 0 评论 -
ios developer tiny share-20161107
今天继续讲Objective-C的Block,讲Block作为参数传递给一个方法,实际上,这种用法是Block的主要使用场景。下面是ios reference官方的讲解:You Can Pass Blocks as Arguments to Methods or FunctionsEach of the previous examples in this cha原创 2016-11-21 11:23:09 · 173 阅读 · 0 评论 -
ios developer tiny share-20161108
今天继续讲Objective-C的Block,讲Block作为方法的参数,按照惯例,一般放到最后一个。另外,讲下使用typeof来定义Block,使得Block在语法上更加简洁、易读。下面是ios reference官方的讲解:A Block Should Always Be the Last Argument to a MethodIt’s best prac原创 2016-11-22 15:31:23 · 183 阅读 · 0 评论 -
ios developer tiny share-20160923
今天讲Objective-C除了继承,还有什么好的办法实现类的定制化Consider Other Alternatives for Class CustomizationCategories and class extensions make it easy to add behavior directly to an existing class, but sometimes原创 2016-10-08 15:50:58 · 173 阅读 · 0 评论 -
ios developer tiny share-20160922
今天讲Objective-C中使用类的继承来隐藏private信息Use Class Extensions to Hide Private InformationThe primary interface for a class is used to define the way that other classes are expected to interact with it原创 2016-10-08 13:41:53 · 153 阅读 · 0 评论 -
ios developer tiny share-20161101
今天开始新的一章,讲Block,C、C++、Objective-C都支持Block,就类似closures和lambdas。什么是Block,Block怎么用,今天开始讲。下面是ios reference官方的讲解:Working with BlocksAn Objective-C class defines an object that combines data原创 2016-11-11 13:31:08 · 228 阅读 · 0 评论 -
ios developer tiny share-20160921
今天详细讲下Objective-C中extension和category的区别Class Extensions Extend the Internal ImplementationA class extension bears some similarity to a category, but it can only be added to a class for which原创 2016-09-29 17:34:12 · 173 阅读 · 0 评论 -
ios developer tiny share-20161017
今天讲Objective-C的NSValue,它可以代表更复杂的Objective-C的类型,比如NSRange,结构体类型。Represent Other Values Using Instances of the NSValue ClassThe NSNumber class is itself a subclass of the basic NSValue class,原创 2016-10-25 18:36:44 · 161 阅读 · 0 评论 -
ios developer tiny share-20161026
今天讲Objective-C的两个小知识点,分别是NSDictionary和NSNull,NSDictionary接上节,我们讲NSDictionary的检索,可变的NSDictionary,NSMutilateDictionary。Querying DictionariesOnce you’ve created a dictionary, you can ask it for原创 2016-11-07 15:43:35 · 158 阅读 · 0 评论