Archive for

February, 2010

...

WebKitErrorDomain error 101

3 comments

The LogYourRun app uses both UIWebView and NSURLRequest to communicate with the LogYourRun database.  To let users upload and access their data.  These requests often contain fields that the user enter such as running notes, distance, time etc.  I had the WebKitErrorDomain 101 error come up on occasions when users tried to send requests that contained spaces that were not properly encoded.  I was not able to find any documentation on this error so it took a while to figure out what was going on.

WebKitErrorDomain error 101

Once I identified that the issue was that some users had a space in their username it is a very easy fix.  Just use the stringByAddingPercentEscapesUsingEncoding function to have the string properly encoded:

[username stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];

So if you come along a WebKitErrorDomain 101 error – take a look at the URL you are trying to submit and see if all the parts of it are properly encoded.

Share

How to test location and accelerometer functions from the comfort of your home

1 comment

The LogYourRun iPhone app uses both the GPS and the accelerometer functions of the iPhone.  Neither the GPS nor the accelerometer can be accessed on the iPhone simulator so to circumvent this I used the following methods:

Accelerometer: Otto Chrons has a great Google code project which contains the code for an app that can be run on an iPod touch or iPhone which is on the same subnet as your development computer.  The app will transmit accelerometer data which can be caught by some code that you can insert into your Xcode project.  When you run your app on the iPhone simulator it will thus receive the accelerometer data from the real life device.  This was a great help in troubleshooting the setup of the pedometer functionality.  I was running around in my living room counting steps and comparing to the # of steps on the iPhone simulator.  Be sure to remove the accelerometer simulator code from your application before releasing.

GPS: Everyone who has played with the location manager on the iPhone Simulator knows that you will only get only one location from the location manager on the iPhone Simulator.  Testing the GPS functionality is a critical part of testing the LogYourRun app.  I could run the app on an iPhone and then run/walk/drive around outside – but that would take much too long and the weather in Saint Louis is not conductive to such testing.  Instead I added a button to the pedometer screen of the application which when clicked runs the following code:

- (IBAction) locationButton:(id)sender {
   CLLocation *thisLocation;
   double latitude  = 37.33168900 + (float) ((random() % 100) +1) / 1000000.0;
   double longitude = -122.03073100 + (float) ((random() % 100) +1) / 1000000.0;
   thisLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
   [self locationManager:locationManager didUpdateToLocation:thisLocation fromLocation:thisLocation];
   [thisLocation release];
}

This piece of code creates a random location close to the location that the iPhone Simulator will usually get from the core location (One Infinite Loop). The location is sent to the location manager delegate function of the pedometer class and is handled as if it came from the real location manager. Since the location is different from the previous location the getDistanceFrom: still works.  When I am ready to submit the application all I have to do is hide the two buttons (probably should be done programatically – since one of these days I will forget).

Pedometer showing location and step button

The pedometer screen showing location and step button

Locations shown on map

The random locations shown on map

Share