Feeds

How I wrote an iPhone application

An introduction to the world of mobile Web 2.0

Using blade systems to cut costs and sharpen efficiencies

If an El Reg hack can write an iPhone application then anyone can, so we thought we'd have a go and pass on our experience in the hope that others can build something more useful.

In proper Web 2.0 fashion we decided to create an application which would achieve nothing and have no commercial potential. Therefore, our application would load The Register website and parse its contents to remove all references to the ubiquitous iPhone, replacing the term with a string of the user's choice.

First thing was to download the iPhone documentation from the Apple Developer Connection, which required us to sign up with a valid email address and left us with a small pile of pdf documents to read.

Unfortunately, these documents proved almost entirely useless as they talked at length about the style and usability of iPhone applications, but said very little about how to write them. The JavaScript guides were a bit more useful, but not a lot, and we got more mileage out of our rather elderly "JavaScript Definitive Guide" (circa 1997) and various JavaScript websites.

We also needed to download the latest version of Safari - you're supposed to be able to develop using Safari then deploy straight onto an iPhone, though life is not really that simple, and that does need XP or Vista (or a nice Mac, but our budget wouldn't stretch).

Assuming one isn't going down the native-applications-for-unlocked-iPhones-only route, then iPhone applications are written in JavaScript - an annoying scripting language with aspirations of objecthood and no significant relationship to Java. JavaScripts can't live alone - they are embedded in web pages - but as we wanted our app to load other web pages we made that page a frameset (which can contain other pages).

All our development was done using PFE - we eschewed more complex environments for what should be a bit of quick text editing.

Initially, our frameset only contained a single frame, to load the El Reg pages into, but we had to add a second frame when it became clear that the iPhone's "back" button wasn't going to operate as we would have liked. But even with the second frame for the menu bar our HTML page managed to keep it simple:

<HTML>
  <HEAD>
    <TITLE>Test using frames</TITLE>
    //JavaScript goes here
  </HEAD>
  <FRAMESET ROWS="*,32" FRAMEBORDER="no" onLoad="startUp();">
    <FRAME SRC="blank1.html" NAME="left">
    <FRAME SRC="menubar.html" name="menu">
  </FRAMESET>
</HTML>

Then it was just a matter of inserting our script into the header with a function called "startUp" to be run when the page had loaded, the script is listed in its entirety at the end of this article. blank1.html is just a holding text, while menubar.html contains our additional back button and an option to change the replacement text.

HP ProLiant Gen8: Integrated lifecycle automation

More from The Register

next story
Yorkshire cops fail to grasp principle behind BT Fon Wi-Fi network
'Prevent people that are passing by to hook up to your network', pleads plod
Auntie remains MYSTIFIED by that weekend BBC iPlayer and website outage
Still doing 'forensics' on the caching layer – Beeb digi wonk
Major problems beset UK ISP filth filters: But it's OK, nobody uses them
It's almost as though pr0n was actually rather popular
Microsoft unsheathes cheap Android-killer: Behold, the Lumia 530
Say it with us: I'm King of the Landfill-ill-ill-ill
All those new '5G standards'? Here's the science they rely on
Radio professor tells us how wireless will get faster in the real world
Apple orders huge MOUNTAIN of 80 MILLION 'Air' iPhone 6s
Bigger, harder trouser bulges foretold for fanbois
US freemium mobile network eyes up Europe
FreedomPop touts 'free' calls, texts and data
Oh girl, you jus' didn't: Level 3 slaps Verizon in Netflix throttle blowup
Just hook us up to more 10Gbps ports, backbone biz yells in tit-for-tat spat
prev story

Whitepapers

Designing a Defense for Mobile Applications
Learn about the various considerations for defending mobile applications - from the application architecture itself to the myriad testing technologies.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Reducing security risks from open source software
Follow a few strategies and your organization can gain the full benefits of open source and the cloud without compromising the security of your applications.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
Consolidation: the foundation for IT and business transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.