IOS Project Optimization

Source: Internet
Author: User

/1. Data acquisition downloads (especially big data) are best placed inoperation in Global_queue
Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{  });
The 2.UI update is placed inUpdate in Main_queue (regardless of whether the current thread is in the main threads)
Dispatch_async (Dispatch_get_main_queue (), ^ (void) {          [Yourtableview reloaddata];         });

//Use block syntax to be aware of some of the problems that self's cyclic application causes (such as inability to dealloc, etc.) use   __weak __typeof (self or   __weak xxxviewcontroller *weakself = self; 4. Image loading use, large image using Method 2 or 3//Method 1If you load this way, it will always be in memory as long as the program does not exit. It just loads once, it's in memory, so the second load is fast.
UIImage *IMAG1 = [UIImage imagenamed:@ "Image.png"];  

Method 2     This mode of loading is loaded again because we have freed it. UIImage *image2 = [UIImage imagewithcontentsoffile:[[nsbundle mainbundle] pathforresource:@ "Image.png" OfType:nil]];  Method 3  NSData *imagedata = [NSData datawithcontentsoffile:[[nsbundle mainbundle] pathforresource:@ "Image.png" Oftype:nil]];  UIImage *image3 = [UIImage imagewithdata:imagedata];  UIImage  *image=[uiimage imagewithcontentsoffile:@ "File://doucment/image.png"];
Seven bull pictures some small avatars using the thumbnail 5, a lot of UI and data when using lazy loading method to load

IOS Project Optimization

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.