bloggandomene

elbryan's blog

MapKitDynRoutes: Handle iOS4 routes dynamically

Posted by elbryan Tue, 20 Jul 2010 11:12:00 GMT

Since iPhone iOS4 has released I’ve been working on the new features brought by the new version of the OS.
One of the most useful thing (to me) introduced by iOS4 is the capability of drawing routes directly on the map using public APIs.
How that works is fairly simple: given two or more coordinates it generates a Polyline and put it on the map. This line automagically rescales/resizes in order to maintain the correct aspect even when zooming/panning.

Unfortunately, this new object doesn’t allow developers to update the line with new points. The only thing you can do is to destroy the line, remove the overlay from the map, recreate a line with all previous points plus the new one, generate the respective line associated with the map and add it (as overlay) on the map itself. This is quite a waste of CPU cycles.

I’ve written a set of two classes that tries to handle the Polyline growth automatically.

The project is called MapKitDynRoutes and the libraries are FFMapRoute and FFMapRoutes.

MapKitDynRoutes is shipped with a Demo project that shows how to use the library. It contains, furthermore, a small object FFLocationManager that simulates the GPS behaviour by injecting coordinates to the application using a timer and reading those from a CSV file.

MapKitDynRoutes is released under MIT license.


Posted in , | Tags , , | no comments |



Where should I put my own code?

Posted by elbryan Sun, 13 Jun 2010 22:56:00 GMT

This is a question that you probably already asked yourself when you start developing something and you want to be supported by an SCM tool.
There are tons of solutions in the Internet and most of them are great for the most of the purposes a developer (or a team) might have.
Websites like, just to name few of those, github , repo or cz , Google code or Sourceforge are great if you are planning to develop something open-source related or just to publish some code you don’t mind others to read, copy or fork.

On the other side, there are few borderline cases that require more attention.
One of those cases happened to me when I started developing my Bachelor’s Thesis. I didn’t want an open-source, public browseable SCM because the purpose of my thesis was (still is) unknown so I didn’t know if the code should have stayed closed, private because my University had planned to acquire it once the development would have been completed.
I remembered that, during few exams and for a small indie project, I used Assembla and, as a matter of fact, I found it really great for my purposes. When I ran on their site I (sadly) discovered that there was no more a free solution so I started googling for something new.

I hit Unfuddle and I decided giving it a try. Among the plans they offer, I decided that the “free” solution was the one I was looking for. One project, 200mb storage area, infinite repositories, tickets, tracking bug and milestones was what I really need. And the code stays closed. Furthermore, the two people limit was enough for me (me and my supervisor).
My opinion? Really, really positive. I really like the way they handle projects and repositories, mail advertising and all the kind of stuff you are expected to see in a well done software development environment. Not to mention powerful commits: those really boost your producitivity up.
Something even funny happened. If you remember I’m developing an iPhone application and, about two weeks ago or so, they published Unfuddle official application on the App Store. A very convenient solution for me. In fact, I’m used to debug, analyse and test my application while I’m moving so it’s really useful to add a bug/feature report on the way while I’m testing it.

Summarizing it up: I really appreciated Unfuddle for the 4 months I’ve been using it and it will be my first choice if, in the future, I need something similar. In the mean time I advice you to take a look at it if you’re willing to start a new project or thinking about moving your existing code somewhere else.


Posted in , | Tags , , , , , , | no comments |



iPhone OS: iPhone 3 Development

Posted by elbryan Mon, 08 Feb 2010 09:28:00 GMT

Today just arrived the book I ordered from Amazon

It’s time to read some official resource and stop doing code&fix things.

For the fella interested in the book I bought, it’s named Beginning iPhone 3 Development: Exploring the iPhone SDK and it’s written by Jeff LaMarche and David Mark


Posted in , | Tags | 2 comments |



iPhone OS: Day 7, Hope

Posted by elbryan Thu, 28 Jan 2010 00:26:00 GMT

Thank you again Ayreon

Today I made few improvements around iPhone OS. I’ve been able to query the GPS and retrieve some data from it. Actually I’m using the iPhone Simulator shipped with Xcode and I can say that it lacks in fantasy. The Simulator doesn’t provide a real “simulating” environment for GPS since it seems to provide every time the same coordinates.
Actually, I’m expected to develop a GPS-Tracking applications as my Bachelor’s Thesis, so it’s pointless using the same values for tracking a path. That’s a no go. Furthermore the things get more complicated by the fact that I don’t have an iPhone myself. Even if I had it, it wouldn’t be useful since Apple allows developers to install their own applications only if they own a special certificate released through the Apple Developer Program (that costs $99). So, yea, that’s a double no go.

Eventually I’m getting used to Interface Builder: it’s not that bad once you’ve understood how delegation things work and the secret behinds classes associations.

Another thing I’m starting to comprehend are the errors that Xcode spits out. Today I spent an hour trying to understand that an object wasn’t correctly instanced and the errors given by Xcode didn’t help me find it out.
Furthermore today I’ve learned how to “localisating” strings and how to transform objects into locale-capable objects!

Definitely a good day for my iPhone developing experience. Can’t say the same for the Apple Conference held today (where iPad has been announced) that quite disappointed me. I’d really enjoyed something more multi-tasking-ish given the new device presentation. I think this tablet won’t make the difference or echoes like iPhone did.

I’m still hopeful for the next generation SDK (the 4th edition). I really hope it will bring multi-tasking on its devices (and onto my application as well).


Posted in , | Tags , | no comments |



iPhone OS: Day 3, pain

Posted by elbryan Fri, 22 Jan 2010 15:45:00 GMT

Once again, thank you Ayreon.

Today I started developing something more "special". I like the idea of having multipages since the content can be easily surfed with just two fingers. So I've started gathering information about this and I found something really interesting. An iPhone OS Developer can manage program's memory almost as much it likes. In this little application I wrote, there's a bit of memory management since just the pages nearby the current are pre-loaded. For example, if you are on page 3, only pages 2 and 4 are loaded in memory (mainly to avoid glitches when you decide to switch page).

However all that glitters ain't gold! What I'm really finding difficult to understand, is how components work. The main concept is "delegation". Everything delegates to something in a completely mystical way (at least for beginners). Sometimes you think to have full control of what you do. Sometimes you "just click into two spots" and that's it. It's quite confusing.

One thing you have to remind is the fact that delegation means "explicit delegation". Inside Interface Builder application you can put the components as you wish but you've to remember to explicitly delegate those to your previously defined interface; otherwise nothing will work. This has to be done for components as well for methods or events. It's something that you've to get used to if you want something running.

Another painful concept is nib/xib files management. These packages are something that you manage from Interface Builder but they are completely useless unless you full instance them in compile time. The first time I gave a look at Interface Builder, I started thinking that "visual objects" has to belong to "visual interface". That's not completely true. I wrote this test-application in order to understand this behaviour. The two pages that compose the applications are two distinct xib files. Once you've written them, you can put the two xibs instances into an objects array and load them on demand.

It's something like:

	NSMutableArray *controllers = [[NSMutableArray alloc] init];
	
	[controllers addObject:[[Controller alloc] initWithNibName:@"Page1" bundle:[NSBundle mainBundle]]];
	[controllers addObject:[[Controller alloc] initWithNibName:@"Page2" bundle:[NSBundle mainBundle]]];
	self.viewControllers = controllers;
	
	[controllers release];

In this example I create a NSMutableArray and I put inside it two instaces of two NIB files. Something that scared me firstly is that release. In the row above you just assign the value to the viewControllers variable and then you release it. I thinkg that "equals/=" means that you perform a copy of the object. Otherwise, in my code, I release something that's going to be used nextly in the program. KABOOM!! I know that's something really trivial for someone that already knows how iPhone OS works but I liked sharing that with you. Once you've done that, your array will contain two "pages". In order to pop them when you switch page, you'll have to do the opposite. Something like:

	- (void) loadScrollViewWithPage:(int)page {
		Controller *aViewController;

		aViewController = [viewControllers objectAtIndex:page];
		[scrollView addSubview:aViewController.view];
	}

This snippet says that you have a method that does "something" whenever you change the page currently showed. Declare a Controller instance, grab from viewControllers (the NSMutableArray used above) the object at index page and then add it to the Subview. Subview is simply what you are looking at on the device (not sure if that hides something more).

Since I'm starting right now to learn programming in Obj-C / iPhone OS , I might have made some mistakes above. If you notice something weird, please let me know. Thank you.


Posted in , | Tags , , , | no comments |



iPhone OS: Day 2, Isolation

Posted by elbryan Wed, 20 Jan 2010 22:41:00 GMT

I hope Ayreon would forgive me for robbing a name from their album, The Human Equation.

These days I'm reading a lot of documentation regarding iPhone OS since I think I'm going to develop something related as part of my Bachelor's Thesis. Sincerly I'm a bit scared about this environment: being a Linux user doesn't ease my travel for sure but this device catch my attention for a lot of things. For instance I like very much the User Interface. I like how Apple designed the OS from a graphical point of view. I can easily say the same for the SDK documentation, it's really really well done. There are tons of examples, tons of documentation; there's even a mini-little tutorial for Object-C newbies.

But, well, as you may already have understood, I really dislike how the Operative System works. It's so darn closed that scares the Hell out of me. The thesis, if I'll accept it, would be an application for GPS Tracking with some other funny features like Geo Tagging, Compass usage and so on. So I've started thinking about what would ever happen if during my walk suddenly a call incomes. iPhone doesn't allow more than one application to run in foreground so the choices are only two: or you get the call, or you track your walk. 2010, dudes! I can't believe we still are forced to be tied with such things. Yea, I know. Security purposes and battery saving. Apple: spend your money on OS optimization and low-consumption hardware! (or ask Nokia how can they produce 12h devices). Well at least we can change the battery. Nope, we can't.

However, why isolation? Isolation came to my mind because of the device itself. It's completely closed. You can't install your own applications without paying a 99$ for being recognized as "Apple Developer". You can't develop an "Hello world" nowhere but Mac OS X. You cannot even try your own bloody-written application that use GPS without paying that fscking 99$. My professor told me:"Well, you still can develop some pseudo-random algorithm to feed your data analysis with". It's outside of my world, it's something I might not even conceive. After all I'm going to grit my teeth because I think that a thesis has to be as explorative as possible. I won't like the idea to put my effort in something I already know. Furthermore, iPhone has a lot of customers (with money) and a nice showcase for applications.

Don't know what will happen. I've already started buying a book. I think I'll sell it before it's shipped to my home.


Posted in , | Tags | no comments |