Introducing APTokenField

April 1st, 2012 Comments off

Working on Line2, I wanted to emulate the message composition screen Apple uses in iMessage and in the MFMailComposeViewController class. Specifically, I wanted to emulate the ‘To:’ field so I could use it in the SMS message composition screen in Line2. At the time, the only option that met the need was TTPickerTextField (part of Three20). I finally bit the bullet and integrated it into Line2, but it had some drawbacks, the biggest being that you have to integrate all of Three20 to use it.

After awhile, I got an itch to remove my dependency on Three20, so I wrote APTokenField. A lightweight, stand-alone implementation of the TTPickerTextField functionality. First some pictures to show what it’s capable of:

APTokenField screen shot 1

APTokenField as used in its sample app

APTokenField screen shot 2

APTokenField as used in Line2

Let’s take a look at the available features:

  • You can specify a text label to be displayed on the left side of the token field.
  • You can specify a custom rightView, that does whatever you want it to do. Just set the rightView‘s bounds and assign it to the APTokenField’s rightView property
  • Support for multiple lines of tokens. Even when the number of tokens is large, the view scrolls up to let the user see the result set.
  • Easy to use in your parent view’s layout. No need to mess around with UIScrollViews. Just add it to your view hierarchy and set it’s frame to whatever size you want. The table of results will automatically hide when there are no results, and it will take up whatever area is available in the frame.
  • Everything is contained in two source files. No images required.

If you wanna jump right into it, head over to the APTokenField github page and clone away. Otherwise, here’s a brief tutorial to start using it.

  1. Add APTokenField.h and APTokenField.m to your project
  2. Add the QuartzCore and CoreGraphics frameworks to your project

Let’s take a look at the project in the APTokenField repo. It contains a controller (APTokenFieldController) and a data source (AmericanStatesDataSource).

The data source conforms to the APTokenFieldDataSource protocol, which lets the user search the 50 American states and add them to the field by tapping a result. The meat of this class happens in the four required methods, which search and return values from the array of American states. As the user types characters into text field, the -(void)tokenField:searchQuery method will be called with the current text. It’s up to you to decide how to implement your search, but for this simple example we just check if the search text exists in the name of any of the states, and if it does, the matching state gets placed into the results array. The table of results gets updated automatically in the UI, and you don’t have to make any complicated callbacks when you’re done (I’m looking at you Three20).

If you want to get feedback on when the user adds and removes tokens, you can implement the APTokenFieldDelegate protocol. If you wanna use a custom UITableViewCell for the results, take a look at the optional methods in the APTokenFieldDataSource protocol.

You should follow me on Google+.

Categories: iPhone, Open Source Tags:

Uncanny valley

September 21st, 2011 Comments off

The uncanny valley from Wikipedia:

The uncanny valley is a hypothesis in the field of robotics and 3D computer animation, which holds that when human replicas look and act almost, but not perfectly, like actual human beings, it causes a response of revulsion among human observers. The “valley” in question is a dip in a proposed graph of the positivity of human reaction as a function of a robot’s human likeness.


Categories: Links Tags:

Sync Music and Playlists with Android Using Songbird

May 23rd, 2010 Comments off

Despite all the amazing things Android phones are capable of, syncing your music and playlists is not as easy as it should be. On Windows you can use Windows Media Player, but that’s obviously a no-go on Linux and OS X. So for the benefit of all, here are the steps to get syncing working for your Android phone (I use a Nexus One, but the process is not device specific).

  1. Download Songbird.
  2. Install Songbird. On OS X, double-click the disk image you downloaded in the first step, then drag the app into your Applications folder.
  3. Launch Songbird from your Applications folder. The first time takes awhile, but just be patient.
  4. Click through the license agreement, and you’ll be presented with the Songbird Setup wizard. If you’re on OS X or Windows, you’ll see the iTunes Import/Export wizard page. Go ahead and check Import tracks and playlists from iTunes. I’ve switched completely over to Songbird now so I can’t say how well the export functionality works.
  5. The next page has a list of recommended Add-Ons that are checked by default. I only selected LyricMaster and Gracenote. If you happen to have some DRMed files that you bought from the iTunes Store, you’ll need to check QuickTime Playback as well in order to play those on your computer, but even with that checked, you still can’t play those files on your Android phone (remember kids, DRM == bad).
  6. At the next page, decide whether you want to send metrics to the Songbird devs, then hit ‘Finish’. Wait for Songbird to restart.
  7. Once it’s launched go to Tools->Add-ons then click the ‘Get Extensions’ link at the bottom right of the dialog. Search for ‘foldersync’ in the new tab that opened and click Search. Click the Download button for the FolderSync add-on and when prompted, select ‘Install Now’. After installation completes, restart Songbird.
  8. After Songbird restarts, drag up the drawer at the bottom of the application window. Click on the arrow at the top left of the drawer and select FolderSync. If this is your first time selecting FolderSync, you’ll be prompted with a message about syncing. Read it and click OK.
  9. Now hook up your Android phone (Nexus One, DROID [Incredible], Hero, myTouch, Dream, EVO, whatever!) to your computer via USB. Slide down the notifications drawer on your Android, select the ‘USB connected’ notification, then tap ‘Mount’. Your phone’s MicroSD card will show up on the desktop.
  10. Double-click the sd card and make a new folder called SongbirdMusic on there. This will be the folder where FolderSync/Songbird will store all your music. You can call it whatever you want, but I’ll continue to use SongbirdMusic in the rest of the directions.
  11. Go back to Songbird, and in the drawer that contains FolderSync, click on Preferences.... In the dialog that opens, check the box for ‘Write M3U-Playlists’ and uncheck the box for ‘Delete not needed Files and Directories. Press the Escape key to dismiss the dialog (I have no idea why there’s no OK button there).
  12. Back in the FolderSync drawer, click the ‘Browse’ button, find the SongbirdMusic folder we made earlier and click ‘Open’.
  13. Now select whatever playlist(s) you want synced to your Android, then press ‘Start Sync’.
  14. When it’s done syncing, eject the SD card from OS X, and ‘Turn off USB storage’ from the notifications drawer on your Android phone. Android will rescan your SD card (‘Preparing SD card’) and then your synced music and playlists will show up in the Music app when it’s done.

That’s it! To sync in the future, just plug your phone into your computer, mount the SD card, make sure the path to the SongbirdMusic folder is in the ‘to folder’ of FolderSync, then press ‘Start Sync’.

Categories: Android Tags: , ,

Presenting, Appirater

September 7th, 2009 16 comments

Like most developers, I’m not thrilled with the way the App Store presents my apps. There are several problems, but in particular, I really don’t like the user review system. It’s biased towards bad reviews, and that ends up hurting sales (there are odd exceptions to this). The only time a user is reminded or asked to rate an app is when you delete it, and you probably don’t care for the app if you’re deleting it. In comparison to the unhappy user, the satisfied user rarely takes the time to review your app. Which leaves you with crummy reviews from uninformed users hurting sales of your app.

If Apple would allow developers to respond to reviews, or more easily challenge the validity of a review, this would be no big deal. But I don’t have any hopes of Apple wising up and fixing anything, so I’m left trying to get more positive reviews of my apps to drown out the negatives ones.

The goal of Appirater is to encourage your satisfied user’s to rate your app. To use it, place the Appirater code into your project, and add the following code in your app’s delegate class.

// import the Appirater class
#import “Appirater.h”

@implementationMyAppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// all your app’s startup code
    // …

// call the Appirater class
    [Appirater appLaunched];return YES;


Finally, open up Appirater.h and change the APPIRATER_APP_ID to your apps software id. You can also change the other #defines, for a more customized reminder message and buttons, but the default should suffice for most apps.

Now every time the user launches your app, Appirater will see if they’ve used the app for 30 days and launched it at least 15 times. If they have, they’ll be asked to rate the app, and then be taken to your app’s review page in the App Store. If you release a new version of your app, Appirater will again wait until the new version has been used 15 times for 30 days and then prompt the user again for another review. Optionally, you can adjust the days to wait and the launch number by changing DAYS_UNTIL_PROMPT and LAUNCHES_UNTIL_PROMPT in Appirater.h.

Appirater as used in Prayer Book app


BTW, if you like Appirater, please consider checking out my game, Jabeh or the lite version of it.

UPDATE: Ivan Nikitin has made a MonoTouch port of Appirater.

Cheap iPhone data plan with T-Mobile USA

August 25th, 2009 16 comments

Just a quick post for everyone who’s lucky enough to be using T-Mobile on their iPhone in the US. It’s possible to get a data plan for your iPhone at only $9.99. It’s edge only, but that doesn’t matter because T-Mobile’s 3G network is incompatible with the iPhone’s 3G radio.

Here it is:

  1. Log into your account at Change your device to be a silver (the pink one won’t work!) Motorola RAZR.
  2. As of this writing, there’s a bug in the site that prevents you from seeing the correct data plans for your newly selected device, so log out of the site, then log back in again. Now fFind your way to the page that lists the possible services you can add on to your plan, and you should now be able to select a $9.99/month web plan ($20 gets you unlimited texting as well). Select it.
  3. In your iPhone go to Settings->General->Network->Cellular Data Network and for the APN use Leave the username and password blank.

You might need to wait up to 24 hours for the service to be activated. Just keep restarting your phone periodically and check to see if it starts working.

Categories: iPhone, Tutorials Tags: , ,

How To: Get a Video Screen Capture from Your iPhone

August 15th, 2009 Comments off

I just setup my iPhone so I can control it remotely and ultimately perform video captures of my activity on it. It’s a quick and painless process, and here’s a step by step for those interested:

  1. Jailbreak your iPhone/iPod Touch There are various tutorials around that take you through the jailbreaking process. Just make sure to use the latest version of the jailbreaking tools and install Cydia if you’re prompted.
  2. Launch Cydia and install Veency If this is your first time opening up Cydia, you’ll be prompted about what mode you want the program to run in; select ‘User’. Next click on the Sections tab at the bottom, select the Networking section and scroll down until you see Veency. Select it and press Install.
  3. Download and install a VNC client If you’re on OS X, you can download Chicken of the VNC. On Windows, you can use Tight VNC.
  4. Find your iPhone’s IP address On your phone go to Settings->Wi-Fi then click the blue disclosure button for the network you’re logged into. Take note of your iPhone’s IP address, because we’ll need it later. Mine is
  5. Launch VNC and connect to your iPhone Make sure your iPhone is unlocked and logged into your Wi-Fi network. Launch Chicken of the VNC (or Tight VNC) from your desktop, type in your iPhone’s IP address for the Host, and leave the Display at 0, then hit Connect. You should see a prompt on your iPhone asking you to accept or reject the connection. Veency Prompt
    Go ahead and accept.
  6. Control the iPhone You can control the iPhone with left-mouse clicks and the keyboard. You can simulate a press of the ‘Home’ button with a right-mouse click, and you can simulate the ‘Sleep/Power’ button with a middle-mouse click.
  7. Capture the iPhone screen I like to use Screenflow on my Mac to capture screencasts. I’m not up to date on the best screen capturing software for Windows, but I’m sure there are plenty of options out there.

A couple caveats: The frame rate’s not that great, which produces some artifacts during animations, and any app that uses OpenGL doesn’t work at all.

Categories: iPhone, Tutorials Tags:

Get the browser’s user agent with mod_python

August 7th, 2009 1 comment

I recently discovered the beauty of mod_python and python server pages (psp), and I’ve been slowly replacing the php code on my server as I make changes. One thing that took me awhile to figure out was how to get the user-agent of the requesting client. In the hopes of helping others in the same boat, here’s the line of code:

<%= req.headers_in['User-Agent']  %>

As you can see all the request’s header information is in the req.header_in dictionary.

t-zones is even easier to setup now

May 11th, 2009 9 comments

After restoring a family member’s iPhone that was acting up, I began setting up t-zones for them, but couldn’t find the t-zones hack in the BigBoss repository. After some experimenting, I soon realized that none of the proxy configuration work is required anymore either. Setting up t-zones on your iPhone is now an easy 3 step process:

  1. Go to Settings->General->Network->Cellular Data Network
  2. Type for the APN (leave the username and password) blank
  3. There’s no step 3!

That’s all there is to it. YouTube even works over t-zones now.

BTW, if you’re a long time T-Mobile customer, you can call in right now and ask about the loyal customer plan. If you’ve been with them long enough, you can have a plan which gives you unlimited minutes for only $50 a month.

Categories: iPhone, Tutorials Tags: ,

The price of Jabeh

April 16th, 2009 4 comments

I’ve received a few emails about the price of Jabeh on the app store, so here’s my reply to all of them. :-)

I understand that Jabeh is more expensive than the alternatives out there, but I think the quality of the app and the puzzles more than make up for the difference. The quality of the programming, music and graphics speak for themselves, so I’ll leave that be. With respect to the puzzles, the puzzles in the other apps are very poorly made (probably generated from a poor algorithm), and as a result they’re just not that fun to play. Granted there are 1000+ of them, but the easy puzzles are insultingly easy (3+ zero rows/columns in an easy puzzle?? c’mon!) and the more difficult puzzles require outright guessing, which is not Shinro anymore.

All the puzzles in Jabeh are hand made, so every little twist in a puzzle is something that my friend (and sometimes I) has thought through and thought the player would enjoy. Additionally, you never have to guess to solve a puzzle. You just need to break out those skills of deduction to figure it out. :-)

Not that I haven’t considered lowering the price of Jabeh. When I first launched Jabeh, it was only $1.99, and it didn’t really catch on. So I lowered it to $.99 in hopes of it picking up steam, and still nothing. I raised the price up to $2.99, then to $4.99 where it is now, and demand tapered off only very slightly. It seems most of the people who are interested in a high quality puzzle app are fine with paying $4.99, if it means they get to play it in a beautiful interface with great content. The $2 difference in price isn’t worth the frustration of dealing with an inferior app.

I guess my point in this is that if my app would have picked up and rocketed to the top of the charts at $.99, I would have gladly left it there for all to enjoy and for me to make my profit in volume. Since that’s not that case, I’m fine with leaving it at $4.99 so I at least make some cash to make updating the puzzles and the game worth it (because at $.99, I would have stopped a LONG time ago).

Now, I’d like to throw down the gauntlet here; if people can generate enough buzz about Jabeh to make it start climbing the app store rankings, I’ll gladly return the favor by lowering the price. I’ll start with a modest goal of getting Jabeh into the top 100 of the board games category, and if that happens I’ll lower the price to $3.99.

Also, if you’d like to check out a very interesting post on iPhone app pricing from another developer, this piece by David Frampton is well worth a read.

BTW, I’d like to thank all the Jabeh players for supporting my app, and I hope you guys continue to enjoy all the puzzle updates. And don’t worry, I haven’t forgotten about those feature requests (work has just been getting in the way).

Categories: Uncategorized Tags: ,

Jabeh: Puzzle Game for iPhone and iPod Touch

February 25th, 2009 Comments off

The project that I’ve been working on for the past couple months has finally come to fruition, and is available for purchase on the iTunes App Store.

Jabeh is a puzzle game where you search for 12 hidden stones on a board. Arrows on the board point in the direction of one or more stones, and the column and row numbers show how many stones are in the respective column and row. Using deduction you can figure out where the stones can’t be in order to ultimately find out where all 12 stones are. While you’re playing the game, some light music plays in the background (which you can download for free from the Jabeh website), and when you solve the puzzle you’re rewarded with one of the beautiful pieces of art created exclusively for Jabeh.

You can get Jabeh now for $4.99 or download Jabeh Lite for free if you wanna try before you buy.

Categories: iPhone Tags: , ,