33.读取bundle文件

Paste_Image.png
/**
     读取表情列表
     */
    func readFaceList() {
        let bundle = NSBundle.mainBundle().pathForResource("Emoji", ofType: "bundle")
        let path = NSBundle(path: bundle!)?.pathForResource("emoji", ofType: "plist")
        let data = NSArray(contentsOfFile: path!)
        for item in data! {
            let dic = item as? NSDictionary
            let chatName = dic?.valueForKey("cht") as? String
            let image = dic?.valueForKey("png") as? String
            let imagePath = NSBundle(path: bundle!)?.pathForResource(image, ofType: nil)
            let type = dic?.valueForKey("type") as? String
            let emojiType = EmojiType(rawValue: type!)
            let emoji = EmojiData(chat: chatName!, image: imagePath!, type: emojiType!)
            emojiList.append(emoji)
        }
    }

你可能感兴趣的:(33.读取bundle文件)