Some small knowledge points for iOS (continuous update??? )

Source: Internet
Author: User

Two years have not developed iOS, and recently began to contact iOS development, found that a lot of old knowledge forgotten, a lot of new knowledge is not known.

Recently in the study, some experience to do under the memo, you can also share with you.


The return value type of the initialization method (class name, Id,instancetype)

The return value of the initialization method is typically set to an ID. Why is it? Why not set a class name? If you set the class name, the subclass will not be processed. For example, subclasses want to overwrite the initialization method of the parent class, but want to return their own type, it is not good to handle. So the general return ID type.

But the ID type is not safe. For example, nsstring *str = [Nsarray array]; The compiler checks that it doesn't come, and it crashes when it's running.

Later, after the LLVM compiler comes out, it is recommended to use Instancetype instead of the ID. If the return value is a Instancetype method, the compiler will check the return value, and if it does not return the class or subclass, it will report a compilation error.


The Nsinteger and Int,long
Nsinteger types can represent an int type or a long type, and we recommend that you use Nsinteger because it determines whether to use an int or a long based on the processor of the phone, if the processor is 32-bit , then use a 32-bit int, if the processor is 64 bits, then use a 64-bit long. Starting with the A7 processor (IPhone 5S), Apple starts with a 64-bit processor.

Some small knowledge points for iOS (continuous update??? )

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.