iOS project development Combat--plist Array Parsing

Source: Internet
Author: User

Plist data is an apple-created data format, based on XML, which is often used because it is very convenient to operate plist in a IOS,MAC system. In an iOS project, a info.plist file is automatically generated that contains some configuration information for the iOS project. The root node type of the Plist file can be either a dictionary dictionary or an array of arrays.


Now we try to create a new plist array and parse it ourselves. The specific implementation is as follows:

(1) Under the project directory supporting files, under new files, then select Property list in the popup dialog box. Enter a name, and a plist file will be generated.

(2) The plist file has 3 parts, namely the key, type, value. Where the root root node can only select an array or dictionary, the data type of the other child nodes can be boolean,date,data,number,string. If you select array, this means that this is an plist array, or if you select dictionary, this means a plist dictionary. Let's first select array, then insert some data inside,


(3) Then in the Viewcontroller code implemented as follows, for plist array parsing, output:

Import Uikitclass Viewcontroller:uiviewcontroller {    override func Viewdidload () {        super.viewdidload ()        var array = Nsarray (Contentsofurl:nsurl (FileURLWithPath:NSBundle.mainBundle (). Pathforresource ("Data", OfType: " Plist ")                !!)! For index in array{                    println (Index)}}}    

The output results are as follows:


The plist array has been successfully read and parsed and stored in a normal array format. So that we can easily operate the plist file.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS project development Combat--plist Array Parsing

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.