Ad

Our DNA is written in Swift
Jump

Tap&Hold for TableView Cells, Then and Now

It was before SDK 3.2 that I developed a technique to add tap-and-hold interactivity to your tableview cells. In this article I’ll demonstrate the old technique, which still works, and contrast it with how much easier it has become if you can target iOS 3.2 and above.

First the “old way”. It needs to customize touch handling for the tableview cells themselves, which means you have to subclass UITableViewCell.

Read more

MyAppSales for Partners

A user of MyAppSales approached me and asked for the possibility to pre-configure the app such that he could give it to a partner of his. The goal was twofold:

  1. Pre-configure the account for iTunes Connect such that you don’t have to give your credentials to your partner
  2. Filter sales reports such that only the apps come through that the partner is receiving a share of sales for

… and all of this without impacting the other features like review downloading.

Since I have such a partner myself for which I’m now publishing 3 apps, I sat down and – after fighting with Xcode over a second target – added a couple of lines to the MyAppSales trunk to enable the “Partner Version”.

In the PCH file you enable and configure this special version by removing the // in front of the first define. Then you need to specifying your ITC credentials and an NSSet of Apple App Identifiers.

// to enable the partner version, re-enable the following define and fill in the three values below
//#define PARTNERVERSION
 
#define PARTNERVERSION_ITC_LOGIN @"account@server.com"
#define PARTNERVERSION_ITC_PASSWORD @"SECRETPASSWORD"
#define PARTNERVERSION_FILTER_APPS_SET [NSSet setWithObjects:@"335519920", @"329678407", @"374457741", nil]

I’ve added a filter for the specified PARTNERVERSION_FILTER_APPS_SET in two places to ignore all lines on sales report where neither the Apple Identifier nor the Parent ID is in this list. Since the app never sees any apps outside of this filter those also won’t pop up on the apps page.

For the preconfigured account, the app adds this ITC account if there are no accounts defined. So if your partner were to remove this account accidentally it would be configured once more on next app start.

All you need to do after configuring and building a release version is to zip and ship the app and provisioning profile to your partner. Easy enough?

DTBannerManager

You have AdMob ads in your apps? Wondering if you could make a bit more money if you also had iAds were available?

DTBannerManager solves this problem for you. It allows for easily adding both networks to your code. Under iOS 4 it will first try to get an iAd because those also pay for just being displayed. If none is available then it automatically switches to AdMob, so your banner space is never wasted. It also features elegant sliding in and out of the banners and is able to display ad banners even over a tab bar controller, so they are always visible for maximum effect.

You might argue that there are free ad networks out there who promise to do exactly this for free. So why would you want to get this component from me. Well, from you you get full source code and you see exactly what is happening. Also there is no server-side ad mediation happening that might get you in trouble with Apple. I believe that as developer you don’t want to involve too many additional parties and introduce too many external dependencies. With DTBannerManager you continue own all parts of your code and have full transparency.

What’s also great is that you can use this component will work on both 3.x and 4.x iOS Versions. This way you can target the broadest possible audience with reaping the benefits of iAds if available.

Adding advertising is exceedingly simple:

#ifdef FREEVERSION
	[[DTBannerManager sharedManager] addAdsToViewController:tabBarController];
#endif

Then you can just subscribe to the notifications to adjust the viewing area of your view controllers.

DTBannerManager is proving it’s worth already in GeoCorder [FREE]. There was a bug preventing “clicking through” in Ads that I have since fixed. The component is available through the Dr. Touch’s Parts Store.

CGRect Tricks

CGRect might just be one of the most often used structures that you have in your fingers when coding for iPhone. View frames and bounds are something that you touch way more often than dealing with CGSize or CGPoint values.

So it pays to know about all the nifty utilities that Apple provides for you to make your life easier.

Read more

GeoCorder 1.1.0

Some time ago I got approached by a corporate customer who was looking for a solution to have his vehicles report their location to his server. Previously he had been using Nokia phones and now he was looking to switch to iPhones. So I built a quick app for him, but due to lack of multitasking in iOS 3 it had limited use. But then Apple surprised us with backgrounding for location apps and suddenly make apps like GeoCorder all the more useful.

But I did not think that this mini tracking app by itself would make a good addition to the app store, so I insisted of merging this functionality into GeoCorder. So now GeoCorder can record GPX tracks for photo tagging or viewing in Google Earth and can also ping your server with a customizable HTTP GET.

  • Background Recording on iOS 4
  • UI improvements
  • Completely rewritten backend with CoreData engine
  • FREE Version: iAds on iOS 4 Devices with AdMob fallback
  • User Guide and Support
  • Map View centering on current Location
  • Tracker Mode to ping corporate server with location updates

For the UI you might notice that I moved the recording controls into the navigation bar. Also this is now using a tab bar controller to switch between multiple views with differing functionality. I switched the tracks view and the recording view because for a recording app the recording screen obviously is the more important view.

Once I started to think about the functionality of this app I suddenly had my head fill will lots of additional things, most of which did not make the cut for what is supposed to be a minor upgrade that turned into a 4 day project. For example I had considered adding Google Latitude updating as a Tracking choice. But 1.1.0 is meant to give my customer (and other people with similar logistics use cases) a tool which he can easily install through the app store.

The problem with those many ideas is that nobody is paying for their implementation. On both the full and the free version (ads) I’m making like 10 Dollars a week. Only if I see a dramatic uptake in downloads I will be able to afford implementing more features. But I’m still interested to hear your thoughts should you be amongst those few people who have a use for this uncomplicated app.

Maybe it helps a bit that I am also targeting iOS 3.x which still is the OS of choice for iPhone 3G. Where I previously had only AdMob ads, I have now also iAds on iOS 4 devices with AdMob being the fallback. I’ll report on how that goes.

I just submitted the app to Apple for approval. I tested orders of magnitude more than before and eliminated all bugs that I could find to make this a really high quality release.

Update Aug 6th: The update has been approved. What’s a first is that the review team approved the update first and later wrote a mail to me asking to add a battery disclaimer to the iTunes description. Apparently all apps using background GPS are required to have this in the description:

“Continued use of GPS running in the background can dramatically decrease battery life.”

So I added it. Much obliged!

Update: I found two bugs in the free version for which I just submitted update 1.1.1: Ads could not be tapped on and I had forgotten to include background location support.

Apple Store Down

Update: of course I meant to say that the “Apple Store” is down, not the “App Store”.

Every time the App Store Apple Store goes down the world gasps with excitement. New Macs? Any hardware refreshes?

Here’s a script that you can execute at the command line that will notify you as soon as the store is back up. I found this script here and modified it to use the built-in say command instead of growlnotify which I did not have.

#! /bin/bash
 
until [ 1 -eq 2 ]
do
        echo -n "Checking ..."
        MYVAR=`curl -s http://store.apple.com/us | grep backsoon | grep australia`
        if [ "$MYVAR" == "" ]
        then
                if [ ! -f "/tmp/storeup.txt" ];
                then
                        echo "UP!"
                        say "The Store is up!"
                        echo "1" > /tmp/storeup.txt
                        exit
                fi
        else
                echo "down"
        fi
 
        sleep 10
done

To use it just paste this script into a file storecheck, make it executable and run it in terminal. This runs an endless loop and as soon as the store is up will say “The Store is up!”.

Cells with Switch

When I revisited the settings screen on MyAppSales to add a switch it turned my stomach how I would have added it over a year ago versus to the way I’m doing it now.

The Old Way

Consider the following snipped just to get a similar nausea so that you can appreciate what I am going to show you afterwards. That’s from a random switch in cellForRowAtIndexPath.

NSString *CellIdentifier = @"ServerSectionSwitch";
 
SwitchCell *cell = (SwitchCell *)[tableView dequeueReusableCellWithIdentifier:
		CellIdentifier];
if (cell == nil)
{
	cell = [[[SwitchCell alloc] initWithFrame:CGRectZero reuseIdentifier:
		CellIdentifier] autorelease];
}
 
cell.titleLabel.text = @"Enable on WLAN";
ASiSTAppDelegate *appDelegate = (ASiSTAppDelegate *)[[UIApplication sharedApplication]
		delegate];
 
cell.switchCtl.on = appDelegate.serverIsRunning;
[cell.switchCtl addTarget:appDelegate action:@selector(startStopServer:)
			forControlEvents:UIControlEventValueChanged];
return cell;

So obviously I had created a custom tableview cell, so let’s glance at that as well.

Read more

MyAppSales 1.0.16

Apple changed two column headings on the financial reports because apparently the June reports are the first ones which will also show eBook publishers their revenues.

  • “Artist/Show/Developer” became “Artist/Show/Developer/Author”
  • “Label/Studio/Network/Developer” became “Label/Studio/Network/Developer/Publisher”

There where quite a few hot fixes that I had to put into MyAppSales and also if you look at the code you’ll see that it’s in the middle of being migrated to CoreData. The latter is necessary because the current method of caching everything is really ugly code whereas CoreData will permit me to make the app perform way better and it only fetches data I truly need.

Unfortunately (or fortunately depending on how you look at it) I’m very busy with a major project for the last few months, so I cannot really muster the time right now to carry through this migration. But because this is a point of stability in MyAppSale’s live that I can publish it as a new version. Lots of people where continuing to use the previous “released” version because for some reason they feared that the “2.0 BETA” in the Subversion trunk might be unstable. When in reality it aways was the code I’ve been using on my iPhone.

Speaking of iPhone 4, you still need to build it with SDK 3.2 until further notice for exactly the reason I mentioned above: ugly caching. It works fine on my iPhone 4.

Here are some goodies that I also hacked into 1.0.16:

  • Ability to remove individual reports. For example if something goes wrong during download.
  • You can opt to show a report sum on the overview pages. This is slower because for it the app needs to fetch the sales data, so it will impact scrolling. But if you don’t scroll much then its a useful number to see at a glance.
  • I’m now using the standard currency formatter for all amounts

Please update your copy from the repository as usual.

Dr. Touch #019 – "Hoopla"

Lots of hoopla around “Antennagate”. Was it really worth it?

The show notes and script after the break.

Read more

iOS 4.0.1 Bar Analysis

Being the experimenting kind I took screenshots of my iPhone 4 status bar before and after updating the software/firmware to 4.0.1.

In the Unofficial Apple Testing Labs (which double as my house) I have my summer office in a “back room”. This is at the back of my house due to lesser temperatures. So I was able to test a high db as well as a low db scenario. Note that this is regular GSM/EDGE connections, I don’t get 3G where I live.

The “Death Grip” was performed by cupping the left hand around the bottom of the phone making sure to touch the black strip with the base of my thumb.

You can actually feel how much stronger the reception is with fewer bars. See how much larger they are? 🙂

Read more