IOS Learning Log, ios2015-3-16

Source: Internet
Author: User

IOS Learning Log, ios2015-3-16

Objective -- the C keyword self is equivalent to this in java, but it can replace an object or a class, that is to say, it can be used in both static and dynamic methods. Super is equivalent to the parent class. You can call the nil function of the parent class to be equivalent to null in java. It is a null pointer # used to annotate the code. After commenting on it, if you want to find this code later, you can locate it, generally, in some callback and proxy methods, it is often used to annotate the SEL function pointer address @ select to obtain the class's pointer address in the memory. @ protocol the protocol is equivalent to java's image. Class 2 function description is equivalent to java. in ToStringrespondsToSelector to determine whether A method is implemented, rule 1, function scope A, and write the method in. m, private; written in. h is public B. in java, public private can be used to modify function variables, but it seems that OC can only be used to modify variables. So OC distinguishes between public and private functions. does the H file define the location of 2 description A in. the format returned by B in the m file is [NString stringwithFormat: @ "",...] C. It is estimated that this function already exists in the parent class. We will perform the secondary write operation to print the format character % @ In the NSLog test D. When % @ is used to output an object, objC will call the description of an object to return the corresponding information for output. By default, if we do not override the description method, the output content is the class name and address E. It must be emphasized that do not print the output self in the description, because the description method of the object will be called when the output self is used, this will lead to an endless loop. 3 respondsToSelector1 instance method \ class method 2 determine whether the class has implemented a certain method 3 Format Bool buer = [class \ object repondsToSe] ector: @ select (test method name :); 4 protocol A defines A set of method specifications using @ protocol in ObjC. classes that implement this protocol must implement the corresponding methods. Kids shoes familiar with object orientation know that the interface itself is an agreement specification for object behavior description. That is to say, @ protocol in ObjC is similar to the interface definition in other languages, but the interface keyword in ObjC is already used to define the class, therefore, it will no longer be like C # and Java using the interface-defined interface B. One protocol can be extended from another protocol. For example, the above AnimalDelegate will be extended from NSObject, if multiple protocols need to be extended, use commas to separate them. 3. Different from interfaces in other advanced languages, the methods defined in the Protocol are not necessarily required, we can set @ required and @ optional through the keyword. If this parameter is not set, the default value is @ required (note that ObjC is a weak syntax, and no error is reported even if the required method is not implemented for compiling and running ); the C protocol is implemented through <>. A class can implement multiple protocols at the same time, separated by commas. The implementation of the D Protocol can only be declared on the class, attributes and member variables cannot be defined in E protocol, but methods can only be defined;
F if a declarative class accesses the Protocol and the Protocol has a required function, it can not be rewritten in the Declaration. It only needs to be rewritten in the implementation. 4 Rule 1 inherits 2 encapsulation.

 

Related Article

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.