This is a weird one, yet not weird at all really. I was playing around with Grand Central Dispatch (GCD) in viewDidLoad:
dispatch_queue_t queue = dispatch_queue_create(“com.codebrane.onlineTimeQueue”, NULL);
… some code to retrieve the time from an online service
self.textField.text = responseAsText;
It worked fine when textField was a label but when I changed to use a textField to get the full response displayed, it produced this error:
Tried to obtain the web lock from a thread other than the main thread or the web thread.
This may be a result of calling to UIKit from a secondary thread.
I’ve been working on CBLocation to get OS grid references from iPhone latitude/longitude and all the unit tests were working fine and importing the static library into a test app worked fine both on the simulator and the phone. However, when I ran the app independently on the phone it immediately crashed. Luckily, there’s a way to look at what happened, although it’s not very pretty.
First you need the crash logs from the phone. Plug it into the machine, fire up iTunes and do a sync and I found the crash logs in:
with a name along the lines of:
The crash log is pretty useless without the dSYM file from the build, so what I did was clear out the crash logs directory, then run the app on the phone to get it to crash, then sync it and retrieve the single crash file. I then copied the crash file and the dSYM file:
to a separate crash directory I made. The next piece of the jigsaw is to locate symbolicatecrash. Mine was in:
I’ve started working on a spare time app for the iPhone that lets you find out about the geology in the vicinity of the device. The first version will just tell you what sort of rock you’re standing on. I’m asked this question quite a lot when I’m guiding in the mountains so I thought it would be a fun learning exercise for iOS development and to get an app in the App Store.
The current version converts latitude/longitude to OS grid coordinates but I’m sure I’ll port more of Chris’s code as and when I need it, as well as write some additional functionality.
I’d thought I’d write down what goes on when you tap an App icon on the iPhone as it’s quite an interesting collection of bits ‘n bobs and shows how the code ties up with Interface Builder and nib files and the like. This is based on a new View Based Application in XCode, called HelloWorld, so start up XCode and create one. You can then follow along. In the nib files, where something is in quotes, i.e. “File’s Owner”, I’m referring to objects in Interface Builder and not application classes:
All the app does is display the text “Hello World!” in the middle of the screen, so I can concentrate on the startup without code clutter. (more…)
A simple digest of the Cocoa Memory Management Rules.
Using alloc/new/copy means the object you’ve just created has a retainCount of 1 and you must release it, either as soon as you’re finished with it:
Cake *cake = [[Cake alloc] init];
[cake release]; (more...)
I’ve been delving into iPhone development on a small project to develop an app that lets me see what’s happening on the summit of Cairngorm, using the data from the automatic weather station up there. The app, which I’ve codenamed iAWS at the moment, has a few screens for data viewing graphically using core-plot as well as textually from the summit station. For example, here’s the plot of the average temperature on the summit: