Ad

Our DNA is written in Swift
Jump

Developing iPhone Apps on Snow Leopard

I was quite looking forward to getting a chance to improve my already quite satisfying Mac experience to the latest iteration of the operating system. Having bought my new MacBook Pro after Juni, I was elegible for an extra cheap upgrade. So I filled in my serial number and got promised a delivery about a week afterwards. But not being the patient type I figured it would not be a sin to borrow a friend’s DVD and install the new cat. Hey, I own a license, who cares which media I’m using?

Installation was as painless as can be. You pop in the DVD while your Mac is running, click a couple of times and then you wait. After 20% there is a first reboot, then you wait, all together roughly 40 minutes. At first you don’t see any new stuff, except the same welcome Animation playing in a Window instead of full screen. But then you start to see little things. Many little things, in fact enough to warrant a 23-page in- depth technical review on Ars Technica which is great bedside reading making you dream nicely about your invigorated Mac.

I was excited to install the new Xcode 3.2 from the “Optional Installs” folder on the DVD, then I downloaded and installed the latest iPhone 3.1 SDK for Snow Leopard which in contrast to Leopard is just the SDKs and now Xcode. The Leopard version contains Xcode 3.1.4, which for strange reasons does kind of run, but is “not officially supported by Apple to run on Snow Leopard”. Still, I will show you how you CAN compile against a 2.x SDK. After that I will show you Apple really wants you to do, but leaves it up to SDK diggers to tell the public.

Read more

Love to be Notified!

One of the techniques which I have found to be extremely useful are notifications in Objective-C. Using NSNotification to send broadcasts to all objects in your app is something that I did not see in any other language or framework I visited before. Here is a quick recipe to show how to use them.

Think of notifications as a method of informing all your class instances within your app at the same time. Sometimes there is a global change that does not have a single target like you would for a delegate. Without notifications you would have to keep track of all objects to be informed of the change manually, loop through them and call an update method.

To give one useful example: In MyAppSales you can set your main currency so that all amounts get converted into the currency you are used to instead of showing you Japanese Yen. Now what happens if the user chooses a different currency and you have objects like table views, table cells or your own class instances that need to change something whenever the main currency changes. Enter NSNotification and NSNotificationCenter.

Read more

MyAppSales 1.0.6

There has long been an open feature request for MyAppSales on the Mantis Bug Tracker for displaying a sum total of units sold and royalties earned. Until now I had thought that I would have to rearchitect the way I am calculating sums, but it turns out that a simple SQL statement is fast enough even with almost a year worth of data in the SQLite database.

Apps Screen New LookAnd while I was at it, I also made some additional useful additions and some visual changes.

  • CHANGED: Look of Apps page changed to be closer to AppStore app
  • ADDED: Royalties earned so far and Units sold (coming from Daily Reports)
  • ADDED: Sums are being recalculated when there are new currency exchange rates and after sync
  • ADDED: Smart Auto-Sync. When started the app only communicates with iTunes Connect if there has not been a new report downloaded today.
  • ADDED: “Empty Cache” button on Settings page removes cached app icons, chart cache and other temp files that might have gotten left over in document directory. This also causes the app names to be reloaded from iTunes.

As usual you can update your source code directly from the Subversion repo.

Setting Pre-Compiler Defines

Once you get smart enough to build multiple apps from the same project you probably have to wrap your head around the concept of #define and #ifdef to conditionally activate and deactivate portions of your code. What is somewhat unnerving is that the target build settings change their appearance seemingly uncontrollably and I took a while to work out what triggers this morphing.

The difference lies in what settings you choose in the upper left hand corner of XCode. Only if you select the “Base SDK” setting then the dialog is the most user-friendly.

Base SDK

The build settings for the active target can no be reached by right-click on target, Get Info, build tab. Or alternatively menu option “Project”, “Edit Active Target”. I discovered three places where #define statements can be placed. I am going to show them to you and make a recommendation as well.

Read more

AntiCrack 2.0

I am extremely pleased to announce a major new release of AntiCrack. While the implementation details have changed very little our new lead developer Fabian Kreiser has rewritten AntiCrack from ground up to obfuscate it to the extreme. Also he researched and developed two additional technologies which should immediately make your mouth water:

  • Denial of Debuggers. This makes it impossible for Crackulous to remove encryption.
  • Checking of binary encryption. The encrypted envelope put on by Apple in the review process is now checked for integrity.

Previously existing AntiCrack 1.x users are getting the update for free, for everybody else the minimum donation has been increased to 30 Euros. I switched from Dollars to Euros because the increasing weakness of the Dollar started to get on my nerves.

1.x versions of AntiCrack did not really prevent cracking of apps but provided a comprehensive and easy to implement toolset allowing users to dynamically adapt their app’s featureset to “Lite” once a crack was detected. The groundbreaking 2.0 release also prevents cracking in the first place. This again makes it on par with the professional Kaliap copy protection service offered by Ripdev.

Personally I believe it’s now even superior because you get full source code for AntiCrack, don’t have to pay recurring charges and you don’t have to register all new apps and app versions with an online service. I’ve updated the AntiCrack product description page if you would like to read more.

LuckyWheel 1.1.1

The version with three ones is always something special for me. That’s why I added several features to LuckyWheel 1.1.1 that have long been requested.

  • ADDED: Button to turn on/off sound effects, so you can now listen your your music without disturbance
  • ADDED: End-Of-Round Screen which shows total standings so far
  • CHANGED: You no longer loose all your previous points when hitting “bankrupt” but just the current round ones
  • CHANGED: Game state is always being saved even when on the End-Of-Round screen. Continue then starts with the next round. If this already was the last round then no continue is possible.
  • CHANGED: A new design for the buttons to replace the previously used blue standard buttons
  • FIXED: 2 minor spelling mistakes corrected in proverbs
  • ADDED: Lite Version now showing ad banner whenever a computer opponent has his turn.
  • ADDED: End-Of-Round screen also shows an unobtrusive ad.

Since the Lite version is constantly being downloaded around 400 times per day I gave in to the temptation and added AdMob advertisements. I think they will make waiting for an AI opponent to finish less boring. When it’s your turn they always make room.

And to say “Thank you” to all those people who are downloading the Lite version we have doubled the number of available proverbs to guess for free!

Both versions have been submitted to Apple. Hopefully it can get approved soon so that you can reap all those benefits.
In Review

Update September 4th: After 13 days both updates have been approved and are now in the app store.

Understanding Autoreleasing

Do you really understand when you need to retain and release some object? And what about autorelease? It took me around 3 months before I grasped when to use autorelease and now it’s second nature to me. But when I needed to explain to a coding buddy I was stumped. I found that my approach was one of feeling rather than knowledge.

So I decided it was time to do an experiment to visualize what happens to the retain count and when an instance is really released. So see what’s happening to our crash test dummy class I made a TestClass that overrides all the important methods so that we get an output to NSLog what is happening.

First I want to demonstrate how the retain counter – present in all Objective-C classes – is used to automatically determine when the instance can be freed from memory. Then I am going to show how to use a factory method which returns an autoreleased instance to make your life easier.

Read more

MyAppSales 1.0.5

First day back from vacation I chose an easy thing to do to get back into the saddle. Nothing too complicated because I don’t want to relapse into needing another vacation right away. I fixed a bug in MyAppSales and bragged blogged about it. This formal release contains these updates:

  • CHANGE: All __MyCompanyName__ now changed to drobnik.com
  • FIXED: Login problems after Apple updated iTunes Connect (quick-fixed previously)
  • FIXED: Password not getting properly URLencoded

The last part is especially necessary for you if you have a plus sign or other characters in your password which are not safe in URLs. If you previously experienced such problems please accept my apologies if you managed to lock your iTunes account. This update should fix this problem for you.

The changes which had been necessary to deal with Apple’s update for iTunes Connect had previously been in the repository but now they have a formal version number. As usual you can update your copy from the SVN customer-only repository.

URL Encoding

When transmitting data in the context of the HTTP protocol you often need to encode text in a way that does not interfere with special characters used in URLs. This is of importance if you want to put unicode characters into an URL query but also for simple things like constructing a body for a HTTP POST request. A form post also takes the form fields and puts them into the form that you know from an URL: field=text&another=more. That’s what the HTML content type “application/x-www-form-urlencoded” means.

The first thing that jumps out of the documentation when looking for a standard function to achieve such “URL Encoding” is stringByAddingPercentEscapesUsingEncoding. So that is what I was using for encoding the password for my iTunes Connect class which drives MyAppSales. And until now this worked without a hitch until customer #113 who was the first to use a plus character in his password. The poor guy ended up locking his iTunes account. Sorry!

It turns out that + is an anachronistic special character substitution for a space. I would have expected for it to be encoded properly by the above mentioned method as %20, but this is not the case.

Read more

MyAppSales – Quick Fix

On the very first day of my vacation Apple updated the iTunes Connect site breaking all existing report downloaders.

My hero is Lukas Matablewski who figured out the necessary changes. Stefan Sorin Nicolin, who is hosting the MyAppSales svn repo commited the changes to the trunk. So please update your working copy now.

All of this while I am in a beautiful NO SIGNAL region of Austria…