Aleksandar • Vacić

iOS bits and pieces

In-app language change in iOS app

iOS – and Apple OSs in general – have excellent I18N support. You more or less don’t have to worry about date and number formatting as long as you are following the rules. The essential rules are:

  • all translations are prepared beforehand and compiled into the app
  • language choice is done outside your app, in system' Settings

Fairly often, I have requests from clients to implement in-app language change, which should (at least) instantly translate the app. There is no API support in iOS frameworks for this.

It’s not impossible though.

Masterclass: Core Data tidbits

I have been using Core Data for a while now, several years at least. Over time, I have learned how it works internally and learned to side-step possible issues and shortcomings. The following is a unordered list of tidbits.

Masterclass: KVC magic tricks

KVO is very, very dangerous. No matter how skillful you believe to be, strive to avoid it as much as you can.

If you really need KVO, then use Facebook’s KVOController. Don’t ever attempt to write the required code on your own. Just look at the source code of this Facebook’s bag of voodoo if you need reasons.

Don’t ever use KVO to monitor changes in Core Data objects.

Masterclass - Notifications

One way to declare and assign the notification name is using global strings in .h file:

1
extern NSString *const XXAPIManagerDidAcquireSessionNotification;

then assigning the values in the .m file:

1
NSString *const XXAPIManagerDidAcquireSessionNotification = @"XXAPIManagerDidAcquireSessionNotification";

However, long strings like this are hard to scan when reviewing the code. Thus I prefer to namespace them using structs.