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

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 upright. To achieve this, it was not possible using an out of the box means by iOS, as those automatic features require the app to work in landscape as well as in portrait mode (which, as stated above, my app didn’t).

Categories
In-House Provisioning iOS Xcode

How to Make Sure That You Are Using an Enterprise Account for IPA Provisioning

In my post describing how to »Provision iOS IPA App for In-House Enterprise Distribution« I described the pitfalls when trying (and hopefully succeeding) to make an In-House Provisioning of your iOS app.

Although I mention repeatedly that you need to be sure that you use an Apple Enterprise Provisioning Account, I experienced multiple times that developers tried to perform the In-House Provisioning with a non Enterprise account.

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.

Categories
apple iOS Mac OS X Objective-C Xcode

A Simple Approach to App Localization using Xcode, XLIFF and Objective-C

When it comes to localizing applications for iOS or Mac OS, things get pretty quickly messed up and cumbersome. The tool support by Apple is – friendly spoking – lacking consistency. Especially if you are updating your code and want to update the localization, things get hairy. I do not want to go into detail here because otherwise this post would never end. I would rather like to provide a (simple) solution.

Categories
Cocoa iOS iPad Mac Objective-C Xcode

How to Prevent Dismissing Containing View Controller when Performing a Double-Tap on a UIPopoverController’s Background under iOS8 in Objective-C

When opening up a popover from a modal view (or another popover) on an iPad running iOS 8 and double-tapping on the background of the popover, not only the popover will be dismissed but also the modal view. This behavior was non-existant in iOS 7 and seems to be a bug in iOS 8.

Categories
iOS Objective-C Xcode

Category for Setting Maximum Length of Text in UITextFields on iOS using Objective-C

Unfortunately, there is no property for UITextField that allows controlling the maximum length of text entered into it. Instead, this behavior can, for instance, be achieved by using an appropriate delegate method of the UITextFieldDelegate.

Categories
iOS iPad iPhone Objective-C

Objective-C Category for Location Authorization Request for iOS8 with Xcode 5 Support [Update]

<update date=″17.9.15″>

</update>

When you use the location of the user in your app and want also your iOS8 users to be able to enable using their location, you have to explicitly ask the user for it using this or this selector. There are two problems connected to that:

Categories
apple In-House Provisioning iOS iPad iPhone

Provision iOS IPA App for In-House Enterprise Distribution

EDIT: Please make sure at first that you are using an enterprise account and not a normal account before following any guidelines!

Provisioning an iOS app for in-house distributione is damn complicated. As my efforts to do so were eventually successful, I decided to prepare this comprehensive tutorial documenting my best practice approach for future reference.