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)