IOS Development Review notes (3)-ARC, ios-arc

Source: Internet
Author: User

IOS Development Review notes (3)-ARC, ios-arc

1. ARC

When you call the release or retain statement on your own, an error occurs when the ARC Code is effective, you can use the-fno-objc-arc and-fobjc-arc compiler flags to support both ARC and non-ARC Code in the mashups.

For example, the following compilation supports ARC, while the file code does not support ARC.

# if !__has_feature(objc_arc)//this code do not support to ARC-(void) release{//release your var}#endif

Integrate non-ARC third-party code in the ARC Project: when using a third-party framework that is not compiled through the ARC, use the-fno-objc-arc compilation switch to compile the files in the library. Edit-> Refactor-> convert to Object-c ARC

When integrating ARC Code in a non-ARC project: compilation errors are not encountered, but memory leakage may occur. To avoid such problems, you need to use-fobjc-arc to mark these third-party code compiled through ARC.

2. ARC in the framework

1) Zero weak references

Weak 1 avoids loop reservation by holding a pointer without paying attention to the reference count value. However, when the memory (pointer to memory) is destroyed, the weak reference will be invalid. After the memory is destroyed, access to the pointer will cause the application to crash. The return to zero references the method of returning the pointer to zero after the memory is destroyed to solve the problem.

2) Ownership Modifier

ARC will automatically help us insert retain and release, but we need to give it some tips to destroy the correct time of allocated memory. These tips are the ownership modifier.

  • _ Strong
  • _ Weak
  • _ Unsafe_unretained
  • _ Autoreleasing

The first three can be used for Attribute declaration. The attribute declaration does not require double underscores. The default ownership modifier is _ strong.

Because _ strong is the default value

@ Property (nonatomic, strong) NSString * someString; // equivalent @ property (nonatomic) NSString * someString;

_ Strong is equivalent to retain.


Which one is better for android and ios? For detailed reasons, I am currently engaged in web development. I have 3 years of development experience and want to switch to mobile phone development?

Android is better. At least users have more application resources and more customers prefer

Why is it difficult to learn about ios development?

(1) First of all, the language format is awkward. If you are used to c and java to learn object-c, the syntax looks awkward, but if you are a master, it should be transferred in one week.
(2) There are no books about ios development, and there are fewer books in Chinese. You can only read the official documents of apple, which is hard to understand.
(3) the sdk and xcode are updated quickly. Any books that can be used in the past about xcode cannot be used. xcode has changed a lot and it makes beginners confused.
(4) the ios system is relatively closed, making it difficult for developers to reach the kernel.
If you want to learn how to develop ios apps, you 'd better find someone who knows how to bring you, or you can easily hit the wall.

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.