Archive for tag: IPhone

Finding nearby locations with iPhone GPS and MonoTouch

Whilst developing my latest application I was faced with the issue of finding nearby locations from a SQLite database containing over 60,000 records.  Each record contained a latitude, longitude and location name.

The problem was how to quickly find the closest locations without having to calculate the distance between the current location and target location for every record.

The solution I came up with has two parts.  First, I applied a limit clause to my select statement to only return the top 100 rows within +/- 1 degree of my current latitude and longitude.

One degree equals approximately 111km (61 miles) so by filtering for +/- 1 degree we are effectively selecting the top 100 records within a 222km radius of the current location.

It is then a relatively simple task to calculate the distance between the current location and selected locations and order by distance.

Encoding video for the iPhone

I have used a number of tools in the past for encoding video in an iPhone friendly format, however they have all required the user to know a lot about codecs, bit rates, screen resoloutions etc...

Whilst encoding some recent holiday footage I went searching for a new tool and found a free Video to iPhone Converter application from DVDVideoSoft.com.

What makes this tool unique is that all you have to do is select your source file, the destination folder and the level of quality you would like (Economy, Standard, High).

Converting a four minute AVI file took around three minutes on my laptop using the standard settings and the quality is excellent.

As with most free software these days, the program prompts you to install a search toolbar as part of the installation process as well as attempting to get you to change your default search page.  Simply deselect these options however and you have an easy to use tool for converting video for the iPhone.

Control your PC from your iPhone

touchmouse2I came across a new application from Logitech today that allows you to use your iPhone as a mouse/keyboard to remotely control your computer.

For those with a home media PC this solution will work a treat.  Unlike most remote controls, the iPhone talks to the server over wifi, so you don't require line of site to the PC.  This means that the home theatre PC can be kept out of site, without affecting your ability to control it.

Installing the application on the iPhone is a simple process.  Simply search for "TouchMouse" in the iPhone app store and install the Logitech program.

Once this is done, you will need to install the server side component which can be downloaded from Logitech's website here.

IPhone Programming Books

There have been a number of tweets and forum posts recently about the best IPhone development books for people starting out with MonoTouch.  I have recently purchased three APress IPhone dev books from Amazon all of which have great material for someone starting out with IPhone development.

I would highly recommend these three books and you can see from the other customer reviews on Amazon that I am not alone.  Click on the books below to go to Amazon and read the other customer reviews.

Accessing GPS data on the IPhone with MonoTouch

A lot of .Net developers have probably heard about MonoTouch but are still concerned about how 'hard' it might be to create a useful application.  One of the applications I am currently working on uses the IPhone's inbuilt GPS and I wanted to show not only how easy it is to get this data, but how understandable the code will be for anyone with a .Net background.

First we add a reference to MonoTouch.CoreLocation with the standard 'using' syntax;

using MonoTouch.CoreLocation;

We then create a module level instance of the location manager:

private CLLocationManager locManager = new CLLocationManager();

We can start the GPS location tracking:

locManager.StartUpdatingLocation();

After which we can access our latitude and longitude:

if (locManager != null)
{
  string lat = locManager.Location.Coordinate.Latitude;
  string lng =locManager.Location.Coordinate.Longitude;
}

This article is based on information I initially read on the following University of Texas at San Antonio blog.

Analytics for IPhone Applications

If you ever wanted to know how users are using your iPhone application then Google has the answer.  Google have extended their excellent web analytics package to include support for both the iPhone and Android mobile platforms.
After integrating the code with your application you can use the Google Analytics dashboard to view both:
  • Pageviews
  • Events

Pageviews correspond to views in your application and as the name suggests the event tracking can be hooked into any UI control to monitor how the user is interacting with your application.

For more information about Analytics Tracking for Mobile applications click here.

IPhone Development with MonoTouch

If you are a .Net developer and would love to be able to develop apps for the iPhone without learning Objective-C then I may have your solution.

iphonesmallSome  of you may be familiar with an open source project called Mono which was aimed at making .Net applications run on the linux platform.  A similar project has now been built by Novell called MonoTouch, which allows iPhone applications to be written in .Net.

Having used the project for the past three months, I have to say that I am very impressed.  It is still a bit of a learning curve at the start and the current online help is very limited, however if you can stick with it the results are amazing.

The biggest issue for most .Net developers is going to be the fact that you still need an Mac to run MonoTouch.  Also, although MonoTouch is free to download and run on a simulator, you will need to pay 399 euro to register it before you can download apps to your phone.