Created
September 27, 2017 16:54
-
-
Save vikdenic/0f65a97b03070177892751528622e293 to your computer and use it in GitHub Desktop.
EmojiSelections.swift 9/27 12pm
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