Skip to content

Instantly share code, notes, and snippets.

View shahdhiren's full-sized avatar

Dhiren Shah shahdhiren

View GitHub Profile
@db42
db42 / swift4-plist-extract.swift
Last active February 2, 2019 14:20
Swift 4 recipes: Extract data from a property list
//Property List file name = regions.plist
let pListFileURL = Bundle.main.url(forResource: "regions", withExtension: "plist", subdirectory: "")
if let pListPath = pListFileURL?.path,
let pListData = FileManager.default.contents(atPath: pListPath) {
do {
let pListObject = try PropertyListSerialization.propertyList(from: pListData, options:PropertyListSerialization.ReadOptions(), format:nil)
//Cast pListObject - If expected data type is Dictionary
guard let pListDict = pListObject as? Dictionary<String, AnyObject> else {
return
}
//: Mocks Playground
import UIKit
struct User {
}
struct PushNotificationController {
let registrar: PushNotificationRegistrar
init(registrar: PushNotificationRegistrar) {