Created
September 29, 2017 17:17
-
-
Save vikdenic/9ece6a9f6403a318fc7e1bc8ded9528c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// EmojiSelections.swift | |
// Alamofire | |
// | |
// Created by Vik Denic on 9/26/17. | |
// | |
import Foundation | |
public class EmojiSelections { | |
public static let shared = EmojiSelections(name: "EmojiSelections") | |
public var plistDict = [String: [[String : Any]] ]() | |
public var allEmojiArrays = [String : [EmojiItemCategory]]() | |
public init(name: String) { | |
plistDict = self.swiftDict(name: name) | |
for (genderKey, emojiArray) in plistDict { | |
var categoryArray = [EmojiItemCategory]() | |
for categoryDict in emojiArray { | |
let emojiCategory = EmojiItemCategory(dict: categoryDict, genderString: genderKey) | |
categoryArray.append(emojiCategory) | |
} | |
self.allEmojiArrays[genderKey] = categoryArray | |
} | |
} | |
public func swiftDict(name: String) -> [String: [[String : Any]] ] { | |
let bundle = BuildConfiguration.bundle() | |
let path = bundle.path(forResource: name, ofType: "plist")! | |
let data = try! Data(contentsOf:URL(fileURLWithPath: path)) | |
let theDict = try! PropertyListSerialization.propertyList(from: data, options: [], format: nil) as! [String: [[String : Any]] ] | |
return theDict | |
} | |
public func emojiArray(gender: Gender) -> [EmojiItemCategory] { | |
return self.allEmojiArrays[gender.rawValue]! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment