MacKuba

🍎 Kuba Suder's blog on Mac & iOS development

Accessing user location data in iOS 8

Categories: Cocoa, iPhone Comments: 1 comment

In iOS 8 Apple made some changes to how apps are supposed to request access to location data. If you use CLLocationManager and you don’t make any changes for iOS 8 compatibility, your app might stop receiving location data at all.

Permission types

The biggest change is that apps can now ask to get location data either “Always” or “While Using”:

Read more »

Making iOS apps compatible with iPhone 6/6+

Categories: Cocoa, iPhone Comments: 1 comment

This is the first part of a new (hopefully) longer series of tutorial-like posts. I’m planning to write shorter posts now but more often, based on specific things that I learn while working on my current projects. Let’s see how long I manage to keep this going… :)


Let’s say you have an iOS app that was build for iPhone 5S and earlier. Now that the new iPhones are out, you want to make it work on them too.

If you don’t change anything and just build your app with the latest Xcode and iOS SDK, you’ll see that the app runs on the new iPhones scaled up: the views are rendered on a standard iPhone 5S sized screen and then resized to a bigger resolution like you would resize a static image, together with the top/bottom bars and everything (which obviously doesn’t look good).

To make the app render on the new iPhones natively, you need to let iOS know that it supports them. There are two ways to do that:

Read more »

Tips for creating mobile sites

Categories: Frontend, iPhone Comments: 1 comment

I’ve recently updated my new blog’s layout to support mobile phones, iPhone in particular (since that’s what I’m using ;). Here’s how it looks now:

screenshot screenshot

I decided to use the same HTML for both versions, and use CSS media queries to define how the mobile version differs from the main one – I thought this was the cleanest and simplest solution in this case. For more complex sites, it probably makes more sense to have the two versions completely separated.

Surprisingly, it was quite easy to do once I figured out what exactly I needed to do. Turns out, the hardest part is apparently knowing what to put in your header and what media queries to use. Here are some tips and suggestions if you want to make a mobile version of your site too:

Read more »

Cocoa JSON parsing libraries, part 2

Categories: Cocoa, iPhone Comments: 7 comments

A few months ago I wrote a post about JSON parsing libraries for Cocoa. I compared 4 libraries – BSJSONAdditions, JSON Framework, TouchJSON, and YAJL, I ran a benchmark on all of them, and the conclusion was that YAJL was the fastest and BSJSONAdditions was way slower than the rest.

Last week John Engelhart commented on that post, mentioning his own JSON library JSONKit, claiming that it’s really fast. Of course I had to check if that was true :)

Read more »

The longest names in Cocoa

Categories: Cocoa, iPhone Comments: 7 comments

Ever since I started coding in Cocoa, I’ve been wondering what might be the longest name used for any function or constant in the entire API. Cocoa names can get quite long in general, so the longest one should be really ridiculously long… Of course I couldn’t leave it like this and I had to find out what it was :)

I ran a search for *.h files on the whole disk, and I determined that the interesting stuff was either in /Developer or in /System/Library/Frameworks, so I limited the search to these directories only. I passed the list of all header files through a Ruby script that looked for the really long ones and sorted them by length, and then I analyzed the results to find the winners (I decided to divide them into a few categories).

So here’s what I’ve found:

Read more »

Cocoa JSON parsing libraries

Categories: Cocoa, iPhone Comments: 4 comments

Update: A new post from December 2010 with updated stats is available here.


For a few weeks I’ve been working on a new iPhone application.

Like most of other Cocoa apps I’ve written so far, this app also includes a JSON parser to load some kind of data from a server. The first thing the application does when it starts is connect to the JSON API, download a data file (about 100 KB) and parse it. This used to take about 10-15 seconds on the device, and I thought it was reasonable until I noticed that the HTTP response actually arrives after a second or so. So what was it doing for the rest of the time? I had to find out.

So I did some debugging, and it turned out that the 10 seconds are spent just on parsing the downloaded JSON file. That’s pretty bad… Like in all previous apps, I used an open source library BSJSONAdditions, which I knew wasn’t the fastest one available, but I never had any major problems with it before. On the other hand, I never tested it on a 100 KB file…

I knew there were a few other JSON parser libraries in ObjC, so I decided to make a small benchmark and see how well they all compared to the one I used. The other libraries I tried were: JSON Framework, TouchJSON and YAJL.

Read more »

My top 20 iPhone apps

Categories: iPhone Comments: 0 comments

Yeah, I know that there’s already about 5.4 gazillions of such posts on the web. So what :) I believe that cool apps – especially cool free apps – deserve promotion like this; and although some of the apps listed here are rather well known and popular, some are not.

Most of these apps are free; it’s not like I can’t afford 0.79 €, but I’ve been a Linux user for a few years and I got used to the “free / open source = good, paid = evil” way of thinking. It’s slowly changing, but I still prefer a good free app to a great paid app – unless there aren’t any good free apps available.

I haven’t included any games here – the reason is that I don’t play them a lot on my iPhone; I just don’t have time for that. The only times when I want to play games on it are when I have a bit of time and completely nothing else to do – but in such cases simple logic or board games are enough for me.

So here’s the list (in a rather random order):

Read more »