Hello.
I'm Aleksandar Vacić, professional web developer and wine maker in the making.
Learn more about me or see what I can do for you.
In my Ambient Mood Lamp app, I have a color picker where you can choose the background color by simply tapping the color on an image, like this:

Color swirl
What I need from there is the actual RGB representation of the pixel color. To get that, there’s quite a bit of code involved. A large part of it is taken from Apple’s technical note QA1509.
Pixel color fetching is done in this if block from that article:
if (data != NULL) { // **** You have a pointer to the image data **** // **** Do stuff with the data here **** }
I picked up the code to get the pixel color from some web page I lost track of. This is the code:
int offset = ((w*round(point.y))+round(point.x)) * 4; int alpha = data[offset]; int red = data[offset+1]; int green = data[offset+2]; int blue = data[offset+3]; color = [UIColor colorWithRed:(red/255.0f) green:(green/255.0f) blue:(blue/255.0f) alpha:(alpha/255.0f)];
w is the width of one row of data, and point {x,y} is where the screen was touched. The * 4 in the first line means 4 bytes of raw data per pixel. Well, 4 bytes when your screen res is up to 160ish ppi. On iPhone 4’s Retina Display, with its 326ppi resolution, this should be 8. Which means correct code now is:
int offset = ((w*round(point.y))+round(point.x)) * 4 * [[UIScreen mainScreen] scale];
Welcome to wonderful world of resolution independent programming.
When you have iPhone apps installed on the iPad, chances are they are doubly-ugly: they look pixelated when doubled and their icons are even more ugly extrapolated from 57x57px to 72x72px.
Recently, David Frampton posted great idea how Apple should have done this (the idea got picked by Daring Fireball, TUAW and many others). While idea is great, it’s more than doubtful that Apple would do this.
What Apple would likely prefer is that you, as developer, make an iPad version of your iPhone app and use the full capability of the device. In the process, you’ll create proper iPad icons and no ugliness then. In the Apple’s DevForums, there’s a thread with guidelines on how to populate App–info.plist file and what icon files are needed.
In there, it says that for iPhone-only apps you need to populate CFBundleIconFile key with 57px icon. However, if you move down a bit, you’ll find section on setting up universal app. Do that, even if your app is not universal and voila — iPad will use the proper icon for your iPhone-only app.
The settings above are from my Quickie to do app — here’s before and after:

Quickie icon on the iPad, before and after
Much better looking.
While working on my iPhone app Quickie, I encountered one of many examples why you must always check your code on the actual device.
Quickie uses Core Data for storage and in one particular place I was comparing the NSString variable to a NSString–typed property of my CoreData class, QuickieList. Like this:
if (QuickieList.listName != theListName)
listName is defined as NSString and theListName is obviously that as well. In this particular instance, both of those had the value of “test”.
In the iPhone Simulator (running on 10.6.2) this comparison returned false, but on the iPhone running 3.1.2 it returned true. When changed into:
if (![QuickieList.listName isEqualToString:theListName])
result was the same.
Never – I repeat — never assume that simulator testing will be fine, even for seemingly small things. It can bite you when you least expect it.
If you have UITextField on the page and you need to validate is there something in it (so if yes you can save the input or something), you might do something like this:
if (![addNewCellTextField.text isEqualToString:@""]) { … }
However, this will fail if the field is never touched. That is, until your user taps the field and it gets focus, UITextField.text is nil. Which means that condition above yields true, which is not what you want.
Once it is touched though, this becomes an instance of NSString with value of @””. Thus, always use:
if (addNewCellTextField.text != nil && ![addNewCellTextField.text isEqualToString:@""]) { … }
Watch out for this little trap hole.
iTunesConnect service — a web site that iPhone developers use to manage their published applications — has a separate area that will list all the synced crash reports from the application users.
However, not all of the crashes appear there, or are slow to appear. Thus, if you have a desperate problem with someone’s application, it’s a good idea to pick these up and send them to a developer.
Here’s how, in three major operations systems: Mac OS X, Windows Vista / Windows 7 and for Windows XP.
Application crash logs are transfered to your computer each time you do a sync with the device, in the iTunes. Thus, first step is to sync with iTunes:

Sync the iPhone or iPod Touch through iTunes
On the Mac, crash logs are kept at:
~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
where ~ is your Home folder. Here’s an example:

Crash logs on the Mac OS X. Device name is “iPhone AV” here
There’s the .crash file and .plist file — archive them both and send to a developer. Actually, pick all the files you find there that have the name of the problematic application.
Files are located here:
C:\Users\<USERNAME>\AppData\Roaming\Apple computer\Logs\CrashReporter/MobileDevice/<DEVICE_NAME>
AppData folder is hidden by default, so here’s how to access it. Get into your personal folder:

User folder, with Vista folder path
Now click on the folder (address) bar which will change the display into Windows folder path and add \AppData to it, then click Enter.

When clicked, the address bar changes into regular Windows folder path
This will then show the folder contents. From here, you can follow the path above until you get to the crash logs.
For Windows 7, follow the same procedure.
Location is here:
C:\Documents and Settings\<USERNAME>\Application Data\Apple computer\Logs\CrashReporter/<DEVICE_NAME>
<USERNAME> is your login username. Application Data folder is usually hidden by default, so you need to reveal it in the same way as in Vista — by typing in and pressing Enter.
And that’s it. Easy :) — rest is for developer to sweat it.