Categories
iOS Swift

iOS Swift Array of Plist

Swift 5 code:

func getArrayOfPlist() -> Array {
        let path = Bundle.main.path(forResource: "content", ofType: "plist")
        var contentsArray = [String]()
        if let path = path {
            if let contentsXML = FileManager.default.contents(atPath: path) {
                do {
                    let plistData = try PropertyListSerialization.propertyList(from: contentsXML, options: [], format: nil)
                    contentsArray = plistData as! Array
                } catch {
                    NSLog("Error when decoding contents from \(path)")
                }
            }
        }
        return contentsArray
    }

Example content.plist

Categories
iOS Swift

Swift Extension for Location Authorization Requests in iOS

A while back I wrote an Objective-C category that helps you managing location authorization requests. As I needed the same functionality in a Swift-based project, I did the effort to transfer the code into Swift. You can download the Swift location authorization extension here.

Categories
Cocoa iOS Swift

Cocoapods Swift does not work with use_frameworks! Fix

I have a mixed Objective-C/Swift project and activated use_frameworks! in my podfile because I wanted to use a Swift-based pod. In order to enable the usage of the Objective-C-based pods in your Swift code, I thought it would be necessary to stick to the common approach of including the pods’ header files into a bridging header file and configure the project in Xcode accordingly. Like so.