Summary of detailed issues encountered in IOS development (continuous update ...)

Source: Internet
Author: User

  Lazy loading of variable arrays under 1.MRC and ARC

Lazy loading of variable groups under MRC and ARC, different arrays are initialized differently:

Under ARC:

1 -(Nsmutablearray *) Lazymutablearray {2     if (!  _lazymutablearray) {3         _lazymutablearray = [Nsmutablearray array]; 4     }5     return  _lazymutablearray; 6 }

MRC under:

1 -(Nsmutablearray *) Lazymutablearray {2     if (!  _lazymutablearray) {3         _lazymutablearray = [[Nsmutablearray alloc] init]; 4     }5     return  _lazymutablearray; 6 }

In the MRC should be initialized with [[Nsmutablearray alloc] init], with Alloc, the reference count of the array will be added 1 (using [Nsmutablearray array] Reference count will not be added 1), prevent the array from early release.

  2. Using nsurlsession to request data, processing of request completion

Request data using Nsurlsession, inside the callback method of the request completion-(void) Urlsession: (Nsurlsession *) session Task: (Nsurlsessiontask *) task Didcompletewitherror: (Nserror *) error {}, data processing completed need to call [session finishtasksandinvalidate], otherwise there will be a memory leak, affect the release of the controller, resulting in Delloc method does not execute.

Reference Link: http://blog.csdn.net/hncsy403/article/details/53096071

  Two properties of 3.UINavigationItem Leftbarbuttonitem and Backbarbuttonitem

1 @property (nullable, Nonatomic,strong) Uibarbuttonitem *Leftbarbuttonitem; 2 3 // Bar button Item to use for the back button in the navigation item.

1. For the current page, Leftbarbuttonitem has the highest priority, if the current page is assigned a new value Self.navigationItem.leftBarButtonItem, the current page every time it is push in the upper left corner of the display is the new assignment Uibarbuttonitem.

2. If the self.navigationItem.leftBarButtonItem of the current page is not assigned a new value, but the self.navigationItem.backBarButtonItem of the previous page in the current page is re-assigned, the upper-left corner of the current page displays the Self.navigationItem.backBarButtonItem of the previous page.

3. If neither the leftbarbuttonitem of the current page nor the Backbarbuttonitem of the previous page are assigned a new value, the default Return button appears in the upper-left corner of the current page, with a left-pointing arrow, and the text is the title of the navigation bar on the previous page.

Note: For the 2nd case, when assigning a new value to Self.navigationItem.backBarButtonItem, when creating Uibarbuttonitem, use:

1  ID ) Target action: (nullable SEL) action; 2 3 -(Instancetype) Initwithcustomview: (UIView *) CustomView;

Both methods are invalid, and the return button in the upper-left corner of the next page is still displayed in the style of the 3rd case.

Use:

1 ID) Target action: (nullable SEL) action;

At the time of creation, two images are displayed, one is the left arrow of the system, and the other is the added picture.

Use:

1 ID) Target action: (nullable SEL) action;

When created, the left arrow of the system is still displayed, and the text on the right shows the title at the time of creation.

Summary of detailed issues encountered in IOS development (continuous update ...)

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.