iOS Development Basics-Image Switching (3)

Source: Internet
Author: User

Continuation: iOS Development Basics-Image Switching (2), the code inside (2) is improved with the attribute list plist.

  

The new property List is named Data to obtain a file with a suffix of . plist .

Press to modify the file you just created:

Finally, modify the Infoarray getter Method:

1 //The Getter method of Infoarray2-(Nsarray *) Infoarray {3NSLog (@"need to get an array of picture information");4     //instantiate only once5     if(_infoarray = =Nil) {6NSString *path = [[NSBundle mainbundle]pathforresource:@"Data"OfType:@"plist"]; //Get plist file path 7_infoarray =[[Nsarray alloc] initwithcontentsoffile:path];8NSLog (@"%@", path);9NSLog (@"instantiating an array");Ten     } One     return_infoarray; A}

Benefits of using the Plist file: Separating the data from the code.

Instance code: HTTP://PAN.BAIDU.COM/S/1JHMT2WM

iOS Development Basics-Image Switching (3)

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.