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 …

Figure out iOS Device Orientation Manually with Swift

I had the problem that I coded an app that records video in landscape. Although only landscape orientation is allowed in the app, users would frequently hold the device in portrait mode and produce shitty videos. Therefore, I decided to show a note to the user demanding to hold the device horizontally when holding it …

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.

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 …