3. Use NSBundle and plist in ios, 3. iosnsbundle

Source: Internet
Author: User

3. Use NSBundle and plist in ios, 3. iosnsbundle

1. NSBundle

1> An NSBundle represents a folder, and the NSBundle can be used to access the corresponding folder.

2> Use mainBundle to access any resources in the Software Resource Package

3> Simulator Application installation path/Users/aplle/resource library/Application Support/iPhone Simulator/7.1/Applications

4> implement lazy loading only once

@ Property (nonatomic, strong) NSArray * imageData;-(NSArray *) imageData {if (_ imageData = nil) {// never initialized // initialize data // File: full path // NSBundle: A NSBundle represents a folder // use mainBundle to access any resources in the software resource package NSBundle * bundle = [NSBundle mainBundle]; // obtain imageData. plist full path NSString * path = [bundle pathForResource: @ "imageData" ofType: @ "plist"]; _ imageData = [NSArray arrayWithContentsOfFile: path];} return _ imageData ;}

2. Use of plist files based on poor scalability

* Create a plist

* Let plist load only once



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.