IOS Learning Log 2015-3-17

Source: Internet
Author: User

OBJECTIVE--C a keyword @class import an existing Class ID object type represents any one ObjC object type Block object Type OC is called code block similar to C in function pointer typedef defines data type @Category classification, extended two function three The rule 1 ID a ID can represent any one of the OBJC object types, and the "< protocol name >" After the type is used to constrain an object that is the property must implement the Protocol (note: the object type defined with ID does not need to be "*"); 2 @class A In the. h file if another file's class or protocol is used, we can declare it through @class or @protocol without having to import the file, which can improve the efficiency of the compilation 3 block A block type definition: return value type (^ variable name) (parameter list) (Note that block is also a type); B feels like an anonymous function c variable name can be defined without a typedef with *D block: return value type (^ type name) (parameter list), E block implementation: ^ (parameter list) {operation Body};f Blocks can read the variables defined outside the block but cannot be modified, if you want to modify then this variable must declare _block decoration; 3 Categorya extend existing class and do not need to change the original class B to create a new objective-c file, select the type of class is category, Also to choose the class you want to modify, note that after the creation of the file name, it is composed of the original class name + new class name, it must have that plus sign, for example, NSString extension of the file name is Nsstring+trim, and then see the definition of the class needs to be changed, the original definition of a common class is @ Interface class Name: NSObject, after the extension is @interface class name (extension) For example @interface NSString (Trim) C scope I System or framework Class II contains a number of method implementations, and these methods require different teams Members to implement the Class III contains a number of method implementations that require the members of different teams to implement the D need to be aware of the problem I category can access instance variables of the original class, but cannot add instance variables, if you want to add variables, it is implemented by inheriting to create subclasses. II category can overload the method of the original class, it is not recommended to do so, it will overwrite the original class method. If you do want to overload it, it is implemented by inheriting the subclass. III and the normal interface is different, in the category implementation file instance method as long as you do not go to call it you canAll claims are not implemented in any way. 

IOS Learning Log 2015-3-17

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.