Core Services

How do I get my application to show up in the “Open in…” menu on iOS for a specific document type? – Apple Technical Q&A

When things are not working as expected with push messages, having insight into what is happening at a deeper level than your code, can be very helpful. iOS offer offers a logging feature that captures APSD process information on the device.

To enable logging of push messages install the configuration profile PersistentConnectionLogging.mobileconfig on your device:

Option #1 – Upload the file to a web-server and point Safari on your phone to the file

Option #2 – Send the file via email and open the attachment

With either option you will receive an alert asking if you are good with installing APS/PC Logging.

Read more »

With the release of iOS 7, Apple added support for encoding and decoding data using Base64. In this post we will walk through two examples using Base64 to encode and decode both NSData and NSString objects.

First, we will create an NSString object that is generated by Base64 encoding an NSData object. This will be followed by decoding the Base64 NSString back into an NSData object. We will display the NSString data, both encoded and decoded to make sure all is well.

The second example will encode and decode NSData to/from Base64. This example is relevant if you have an NSData object that needs to be Base64 encoded, or you need to decode a Base64 NSData object (for whatever reason).

Read more »

Post by

The iOS platform has been somewhat handicapped when it comes to games due to the twin stick interaction paradigm prevalent on games consoles. Even having physical buttons that give tactile feedback about what control the player has used existed on the first Atari consoles which hard glass screens cannot recreate.

On screen twin stick controls have improved over the years, but still don’t offer the responsive feedback of dedicated hardware controls, and will always have the problem of obscuring part of the user interface and the action going on in the game.

All this has changed in iOS7, with Apple quietly announcing the Made For iOS (MFi) Game Controller specification at WWDC 2013 and the first three controllers having come to market 7 months later.

The controllers come in two configurations. The standard controller has four face buttons, a d-pad, two shoulder buttons and a pause button while the extended controller has the same with two additional analogue sticks and two additional shoulder buttons. They can be either wrap around controllers with a lightning connection to the device or some extended controllers only connect via Bluetooth, which can also be used on OSX 10.8.

Read more »

One of the neat features of Cocoa is how easy it makes it to serialize objects to various standard formats for storing in a file, or transmission over The Internet.

We’ve covered how to serialize objects to Property Lists (AKA ‘Plists’) and JSON previously, but by default only a small set of standard object types can be saved in this way (e.g. NSDictionary, NSArray, NSString, etc.)

What if you want to save a custom object type; one that you have created yourself? In theory you can write methods to convert your own objects to and from dictionaries or strings, but this is cumbersome, and there are lots of nasty edge cases to think about, such as circular references. There is a better way:

Read more »

Here’s a quick code check for ARC (Automatic Reference Counting):

#if __has_feature(objc_arc)
  // ARC
#else
  // No ARC
#endif

In Part 1 of the series Serialize Objective-C Objects to JSON I wrote a few examples for serializing objects into JSON. Specifically, a dictionary with several key/value pairs as well as an array. In this post I will show the opposite, how to deserialize JSON to Objective-C objects.

It’s important to note that the examples in both of these posts use the NSJSONSerialization class that Apple released beginning with iOS 5. For basic JSON serializing and deserializing no external library is required.

To keep the code focused on the task at hand, rather than include a bunch of networking code to acquire JSON, I will simulate the process and simply read JSON from a file that I’ve added to my project. The file contents are extracted from a Twitter API example that lists JSON for a sample search:

Read more »

I’ve written previously on how to serialize Objective-C objects to JSON as part of a simple Flickr photo viewer. At the time, Apple did not have support for JSON directly within the frameworks, therefore my examples used an open source JSON library. However, since iOS 5 app developers have had the opportunity to use the NSJSONSerialization class to convert objects to JSON and vice versa.

This tutorial will show you how to convert several objects into JSON. With most of my code examples I like to keep things pretty simple, so you can walk away with some working code as a starting point for your own work. This tip is no exception: I’ll create a dictionary object that contains several key/value pairs. I’ll also add an array of objects to the dictionary. I’ll use NSJSONSerialization object to serialize the dictionary into JSON.

Read more »