Google Maps API – Intro

Android | Wednesday February 9 2011 16:44 | Comments (0)

I’ve gotten down to the nitty gritty of actually making an app that uses Google Maps, which means finally trying to get a map on the screen and at least pick up my location automatically.

To get a basic Google Maps app up and running, its surprisingly easy! Yes, to just have the app pinpoint your location using GPS, its shockingly simple! The reason for this is that Google have done all the hardwork for you. All we, as developers, have to do is call the javascript file on the Google servers and hey presto. For example: Geolocation test . Yes, its that easy, providing you have internet access, obviously! The source code, if needed, can be found here: Maps source

In case you’re interested, there are lots of examples on Googles website here: Google Map Examples

So, now we have a basic application that detects the users location and centres the map on it. However, as you can see in the first link above, the zoom level is a bit too high. Also, we will want to add markers on the street corresponding to the coordinates of the bike stations, or whatever place of interest you’re intending to map. This is more complicated and will be covered in the next section! 😀

Brains! Delicious Zombie Brains!!

iOS | Wednesday February 2 2011 16:04 | Comments (0)

When developing for the iPhone, you have to be aware of its memory limitations. For example, the original iPhone had 128mb of RAM, the iPhone 3GS has 256mb RAM and the iPhone 4 has 512mb RAM. Its all well and good to develop solely for the iPhone4 and use a lot of memory, but then that excludes anyone with an older handset.

Also, take into account that the iOS (iPhone Operating System) itself will use up a sizeable chunk of that memory too, and then you’re left with about the same amount of RAM that, say for example,  a Windows 98 PC would have had! iPhone4 specs are 1Ghz, 512mb RAM so maybe a high end Win98 machine! FYI, the iPad is similar specced to the iPhone4, eg same CPU but only 25mb RAM!!

So, what I’m trying to say is, Memory Management is important. Even more so with the limited resources found on mobile devices, like the above Apple products, and also Android phones and the new Windows Phone 7.

We saw in a previous chapter on Memory, Constructors, Destructors, new, alloc and init how to create objects, allocate space in memory, and initialise them, so you should be familiar with that concept.

Now, thats all well and good, but what the hell has that got to do with Zombie Brains???

When debugging, we can use a feature of XCode called “Zombies”. If we allocate space and release it, as we should since we’re such good programmers, then if we have a momentary lapse of concentration and continue coding somewhere else and try make a function call on this object, which has already been released, then we should expect and error. The problem here is, XCode will only give a very general error, eg “objc[123]: FREED(id): message release sent to freed object=0x213d2” or something similarly cryptic. If you are developing a large program with a lot of code, its pretty hard to pinpoint the exact object that you released earlier and subsequently made a call to.

With Zombies enabled, you will be able to find out what type the object was, so that will narrow down the search to a smaller area of code. It will tell you this with an error message similar to this:

NSInvocation: warning: object 0x1234f of class ‘_NSZombie_myClass1‘ does not implement….blah blah blah

The bolded part is the important part. You can focus your search on objects of that type only. It might not make a big difference on small apps, but on large ones, it will save a good chunk of searching!!

So, how do you enable Zombie mode?

On the left pane in XCode under “Groups & Files”, scroll down to “Executables” and expand. Double click on your app name (or right click-> Get Info) and when the new windows pops up, make sure you’re in the “Arguments” tab. Now, in the bottom box where it says “Variables to be set in the environment”, click the “+” button to add a new entry. Type in “NSZombieEnabled” and give it the uppercase value of “YES”.

Congratulations, you now have Zombie Brains in your code!!