Two (More) iPhone development tips (also involves ColdFusion Components)

This post is more than 2 years old.

Earlier in the week I helped a reader with a iPhone issue he was having. From this came two things I'd like to share with folks. Number one - don't use Flash (sorry, couldn't resist!).

First - don't forget that Safari on the iPhone has a development mode. This is critical for getting any type of feedback for JavaScript errors. How do you enable this? Go to your Settings, Safari page. At the very bottom is a Developer menu. Click it and you will see...

Obviously you want to ensure the Debug Console is turned on. Once done, if you return to the browser and rerun your page with the error, you will see a new notice:

Clicking that option will give you some details about the error:

It's no Firebug, but it's better than nothing.

So what's the second tip? The error the user had involved a simple jQuery call to a CFC that returned JSON. It worked perfectly everywhere but the iPhone. Why? The iPhone didn't like the fact that the result didn't have the proper mime type. I asked him to add this line before his cfreturn: <cfcontent type="application/json" reset="true">. Unfortunately this kinda breaks the reusability of the component. To be a bit more abstract, he could add a quick check for URL.returnFormat first and only use the content type when necessary.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by John Farrar posted on 2/11/2010 at 8:53 PM

@Ray, great tip. The one thing that is most annoying to me is the inability to see the HTML and resources that get sent to the iPhone. (or better put, that don't get sent) IMO that is the biggest challenge in mobile device development.

We are releasing an update soon of our sosContent.cfc that helps us deal with issues like this. I plan to do a some videos. The bottom line is there is alot of cool stuff that can be done with skinning web sites. If we package this stuff up and make it approachable, duplicateable and sustainable then in theory we can all be happy. :) Well, at least this type of issue will have a solution. Take a peak on riaforge at the current sosContent and it will give you a hint of where we are going. Oh, we are packaging the technology up into CFish version 2. There is not code on the project for that yet... it is coming. The CFish also includes technology to deliver content to multiple devices. If anyone wants in on the beta (and these libraries; CFish, sosContent are full free OS projects)

Comment 2 by Raymond Camden posted on 2/11/2010 at 8:56 PM

At least with the simulator you can use something like ServiceCapture or Charles.

Comment 3 by John Farrar posted on 2/11/2010 at 9:11 PM

I know what service capture is but you are the second person this week (second ever for me) that mentioned charles. Guess I need to google that. Perhaps you should do a blog post on that.

Comment 4 by Raymond Camden posted on 2/11/2010 at 9:12 PM

I go back and forth. I _believe_ I paid for SC though. I don't know.

I'm using SC a bit more lately because I've switched to Chrome which doesn't support Firebug.

Comment 5 by Ben Nadel posted on 2/11/2010 at 10:25 PM

Oh nice! I have not used that before.

Comment 6 by Adam posted on 2/12/2010 at 12:44 AM

@John: - a java proxy, been around for ages, what we had to use before all this new-fangled firebug stuff :)

@Ray - maybe just me but the cfreturn code you said you added doesn't show up in the post (Chrome/OSX)

Comment 7 by Raymond Camden posted on 2/12/2010 at 3:27 AM

@Adam: Fixed, thanks. I've got a few bugs in my editor. :(

Comment 8 by Chuck Savage posted on 2/12/2010 at 11:01 PM

ServiceCapture is wonderful, but it may not be being updated anymore. If you check the forums here:, the last post was in March of 09. I tried posting a couple times and the posts never show up, since Kevin has to approve all posts.

Comment 9 by Raymond Camden posted on 2/12/2010 at 11:01 PM

I just found something cool. This feature will also give you tips. I was using a specific device width in a meta tag. Safari said it had a tip for me. I clicked to view- and it suggested I use the constant "device-width" instead.

Damn nice.

Comment 10 by Raymond Camden posted on 2/12/2010 at 11:57 PM

@Chuck: Well now thats something I didn't know. I guess I'd encourage folks to use Charles instead.

Comment 11 by Elliott Sprehn posted on 2/16/2010 at 7:23 AM

Gah. I can't believe they still haven't fixed the mime type bug with CFC web services. :(

Comment 12 by Clara James posted on 1/31/2011 at 4:08 PM

Thanks for this informative post an dit will help in Iphone development to whom who is in learning as well as who has some problems in iphone development.

Comment 13 by Sozan posted on 1/31/2011 at 4:13 PM

Excellent Tips! I haven't read such tips and it will benefit in the phase of Iphone development.