Quick update

I’ve been working solidly for the last 7 days, developing, designing and of course learning. I have now finished, save for usability and performance testing, 4 apps.

I’ve already mentioned one of them, the translator. This one had a lot of memory leaks and despite being multi-threaded was not thread safe. However, I practiced and I learned, and this has all been fixed now (AFAIK anyways).

The second app I made is a mood light. The point of this was to do some custom 2D drawing with Quartz and custom views. Very simple app, but good exercise in quite a few disciplines.

Third… slightly more interesting, it is a Wake on Lan app, it lets you start your computer remotely from the iPhone (both locally and over the internet). This was an interesting app to make because it combines a lot of aspects of developing for iOS. It taught me a lot about delegation, the notification center, modal content views, loose coupling between objects, the view hierarchy, C, BSD sockets, Interface Builder , gdb, Instruments, UI design and much much more. It showed me the big picture so to speak.

The fourth app is a network scanner. It scans your local network for other machines on it, for some simple network surveillance. It also includes a ping utility so you can check the latency between all the hosts on the network. It uses ICMP to detect hosts. I spoke to the creator of nmap about incorporating its technology for OS fingerprinting and more robust host detection (not just ICMP but clever things like SYN ACK packets and so much more that I don’t even understand), however it turned out this was not possible on the iOS because the OS doesn’t provide access to raw sockets which is what nmap needs. Apart from the lack of root priviledges under which the app would need to but cannot run, everything in terms of licensing and copyright was in order. Shame.

That’s it for now in terms of actual development, now I am trying to come up with a brand name under which to…well brand, these apps. I need a name, logo and web presence. That will be a whole new learning experience but it will empower me to make all kinds of interesting apps that rely on a centralised data storage and processing for “community” stuff, which should be cool. Especially with the advent of HTML5 and CSS3 and cool things like OAuth and OpenID.

It’s been an interesting 7 days. I don’t think I have worked so hard in my life. I’ve literally spent 14 hours working solidly every day. The upcoming part will be a slight hurdle because I need to start learning again; I need to create a good web presence for the brand (and if things go to plan, future company). Once the web development learning phase is over, it should be nothing but fun. I’m looking forward to that!

It’s 6:16 am, I should really go to sleep.

Short update

That summer went by far too quick and it was great! Now that it has sadly come to an end, I must entertain myself with other things, such as iPhone development–which isn’t that bad!

I’ve update the translator app with some new hi-res artwork, completed the app icon and ironed out some bugs. The app is now pretty much ready for release.

But pictures say more than words:

Screenshot of RC1

Screenshot2 of RC1 on the Springboard

Landscape screenshot of RC1

And as you may have noticed I’m working on another app as well (which is very nearly finished), but more on that in the near future. These are all still “silly” apps which I am making as an effort to learn to code for the iPhone. As soon as I get comfortable, and around the time complacency kicks in, I will start work on something a little more “interesting” ;)

Luka

Translizzle

Been a little busy windsurfing the last few days so didn’t have time to note this immediately, but here it is. My first iPhone app. Translizzle, meet world!

It’s basically a translator app. UX (user experience) was top priority when making this. You don’t need to enter text, then press translate, and then have the user interface change to show you the translation. You don’t need to dismiss the keyboard to see your translation. You don’t need to do anything, just type and the text will translate automatically. Changing languages is one tap away (2 taps if the keyboard is up). The code is multi-threaded so you won’t feel any user interface lag while the translation is being fetched, of course :p. The translated text box autoscrolls as it fills up. The layout is designed to maximise the screen real estate while the keyboard is up, so you can focus on the actual task of translation. Portrait mode is supported. It’s basically built for purpose, no bs. Those are the highlights off the top of my head. Here’s some screenshots…

Will be on the app store soon, for free. Hope you find it useful.

P.S.: The logo and name of the app aren’t final yet.

P.P.S.: Translation engine courtesy of Google. Thanks Google, we love you :)

Luka

UITableViewController & Core Data

There’s progress! Check it out:

UITableView & Core Data

Might not look like much but thats a UITableViewController inside a UINavigationController inside a UITabBarController, driven by a Core Data database using the NSFetchedResultsController. Lots of big words… And I’d like to say that the concepts behind them are simple but some of them aren’t. I mean once you understand them they’re fine, like with anything, but these were a bit harder to learn than the previous ones (such as UIView). I’m talking about Core Data, the rest are pretty straightforward. You see you need to architect your database first, setting up its attributes and relationships. You then get a special handle to your database (an NSManagedObjectContext) which is actually another controller that sits in between your controller and the actual database itself, and maintains a sort of scratchpad for your database. You then formulate fetch requests which are a structured way of saying “Yo database! Insert this info into x”, which you pass to the NSManagedObjectContext instance. If you want the changes you made to the NSManagedObjectContext scratchpad committed to the actual database you call the save: method on it. Thats not all though. The tricky part is the NSFetchedResultsController, which is another layer that sits in between the scratchpad and your controller. And that one is useful because it allows you to execute queries on your db in batches rather than fetching the whole db at once, which could be 10k items…imagine how long that would freeze the UI for (assuming the whole db even fit in memory). Once you get the hang of it it’s pretty cool because it has methods which correspond to the UITableViewController datasource methods–i.e. when the UITableViewController asks you for a cell at an NSIndexPath, you have a similar method that you then call on the NSFetchedResultsController which returns you an object for an NSIndexPath. Lots of controller layers and confusing at first but it’s pretty powerful and very enabling. Well at least thats how I think it works, I’ll probably gain a better understanding once I run into (and sort) some compile- and/or run-time errors. :)

On a lighter note, just went for a swim and a bike ride. Exercise is good when you’ve been staring at a computer for 6 hours straight. There’s a few more things I need to cover such as Mapkit, the GPS, accelerometer and a few more and then I might finally be able to start making some proper apps. I’ve got lots of ideas and can’t wait to finally realise them. Hopefully I’ll make it that far.

Luka

Resurrection & Things one can learn in a week

I’m back. It’s been almost a year since my last post, and I can’t even remember why I quit developing for the iPhone. It’s not exactly like I proactively quit though. I’m gonna try and keep this intro short because I image you as the reader don’t perceive these posts in terms of absolute time, but rather on time spent on iphone development; in other words in terms of progress. So to dedicate this post solely to why I stopped developing for the iphone and the other things I’ve been doing would probably break the flow. For those who are interested I’ll just say that procrastination is a thief of time and that it’s hard to get any work done when you’re not happy (as a person).

Back on track. OK so I just said how I wanted to keep the flow of progress going, well the documentation thereof at least, and now… I’m gonna break my own rule. I cheated. I’ve secretly been busy on this project for the last week or so. I didn’t start posting right away in case I gave up, but I have gathered some momentum now and I think it’s safe to say I’m back. That’s what happened a few months ago (during easter); I continued work for about a week but then quit again–you’ll surely agree at how silly it would have looked to say that I’m back and to then disappear a week later. If you’ve watched Four Rooms you might remember Tarantino saying “The less a man makes declarative statements, the less apt he is to look foolish in retrospect”. Point in case. Oh shit I’ve digressed again, now I’ve got to start a new paragraph, again! This time back on topic for real though.

For the last week or so I have been watching some lectures from Stanford University on a class called “iPhone Application Development”. They are really good! They’re taught by Apple employees and are very concise and very informative. If you want to learn to develop for the iphone, this is probably the fastest way to do it (right). If I had to give some criticism, I’d say how some of the fundamental stuff like delegation could be explained in slightly more detail (it’s conceptually a very simple concept, but the motivation for it is probably going to be very alien to someone who has never come across it before). Also I think the students would benefit if the different types of classes (types of classes here refers to a family of classes with a certain purpose, like the three types of classes in the MVC paradigm) would be introduced abstractly from a top-level perspective of a program first, just so the student has some context of where all these things fit in before they learn about them. But that’s personal opinion and besides, what authority do I have? This course is definitely the best thing I’ve run into for learning how to develop for the iPhone! You can find it on iTunes U if you look for “iPhone application development”, or on the web at cs193p.stanford.edu. There are some assignments on the website which are really good for drilling in the concepts taught in the lectures.

As for progress here’s an app I made (one of the cs193p assignments).

A screenshot of the HelloPoly app

It uses a custom class as the polygon data model, a custom view that overrides the drawRect: method and a controller that mediates between the two. It also has a button which fades a slider in (as an alternative means to control the number of sides of the polygon), this is done using Core Animation. Core Animation is really easy to use; you just specify a start state by calling the UIView beginAnimations:context: class method, you then edit your view by adding in new interface elements, moving existing ones around or whatever other changes, and then specify the end state of your interface (and therewith the end state of the animation) with the commitAnimations method (also a UIView class method). Core Animation then takes care of the rest and interpolates between the start and stop states for you. It’s like magic. You can see the Core Animation code in the background behind the simulator.

To sum up in the last week I’ve learnt about UIView, UIViewController, Application delegate, Core Animation, NSObject, Interface Builder, target/action, MVC (model-view-controller), subclassing, @property/@synthesize, and Core Graphics (not in that order). All this from the cs193p lecture course.

Also, you undoubtedly know that iOS 4 has come out by now. I have downloaded the new SDK but I am still using the iOS (formerly iPhone OS) 3.x SDK because the cs193p lectures were done on there. As soon as I get through the lectures all screenshots will star the new SDK. Just letting you know in case you Mr. Reader are already in the future and your XCode looks different to mine.

At the moment I am learning about UITableView and Core Data, so that’s going to be the topic for the next post. Stay tuned.

Days 5, 6 & 7: C, Objective-C, iPhone media features

Been a bit busy with other things lately so didn’t have time to post. Also for this post I will try to be a bit more concise than in the previous one, I think I might have stepped off topic slightly…

Here’s the progress: Day 5 was spent finishing off the www.masters-of-the-void.com C tutorial. I wrote a tiny bit of code to see if I got the hang of it, and the basics seem to be down. I thought I knew enough to move on to Objective-C so that’s what I did (I can’t tell you yet if that was a good idea or not). I also had a look at a video tutorial by one of the Apple guys on the iPhone’s media features (things like Quartz, UIkit, Core Audio, OpenGL ES, etc…).

xcode helloworld

Most of day 6 was an effort towards learning Objective-C. Didn’t get that far to be honest, I had to focus my attention on some other things as well. So… I learnt the basic syntax, messaging, getter and setter methods, implementation versus interface, and started to touch upon memory management. This is all a bit hazy and I think I will need to go over that before I continue any further. Also I spent about 7 hours doing some ebay “business”, which might have been a waste of time but I had an idea and wanted to try it out, will mention it again if it comes to fruition. Also I had to go and take pictures of a property where I am acting as sales agent. This was also the windsurfing day, which turned out to be a huge disappointment (that’s what I get for calling the wind fickle and coming up with ridiculous phrases like “majestic synthesis”). That was a long day! Woke up at 6 and went to bed at 5:30 in the morning. Needless to say I slept in quite long (until 12) and so yesterday stole a bit of today so to speak.

Which brings us nicely to today, day 7. In the morning I entertained myself a bit with the ebay project (I don’t want to divulge any specific information but I can tell you that it’s an experiment in advertising and pricing strategies more than anything). Anyhow, then I decided to get out the house and work a bit on my health. After all, I’ve just been locking myself up indoors, working like a maniac for pretty much the entire last week. First I went for a swim, did about 700 meters, this was good fun. This was promptly followed up by some music and sunbathing. After that I had to quickly sort some flights/trains out. Then I went for a bike ride, not too long, for about 45 minutes, and most of that time was spent going uphill; the relief not very flat here. And after that I still had some energy left over so I helped my dad chop some wood up. You  could say today was resting day, physical work can be quite liberating (I should emphasise that I mean that in an innocent way because I am quite wary of using that phrase as it has some pretty sinister connotations; if you don’t know what I am talking about, have a google for “arbeit macht frei”). And now we are in realtime so to speak. Plan for this evening: finish of Objective-C. I am again going for the “freestyle approach” and am reading an online tutorial, namely the one over at cocoadevcentral. I find I learn better when I follow my own flow and answer my own questions based on some common sense assumptions as to what I think I need to know, this then initiates a cyclic hunt for answers to questions which spring up more questions, until finally I have no more at which point I would consider my initiation complete. It is quite a disorganised and arguably bad approach, however if I would have bought a book entitled e.g. “programming for the iphone, form zero to hero”, I would probably just loose focus amidst the spoon-feeding monotony of it. This way every piece of information I gather is actively sought, and has a clear context in which to be placed, making it “stick” much better. I made that title up by the way, any semblance to any real book is purely coincidental.

A friend from the Bahamas is coming over tomorrow and staying for two weeks which means I will have to suspend this project for that little while. This is very welcome because the last two weeks of almost continuous solitude have not been the healthiest for my mind. In case you are wondering, this is where I drew my motivation from. I am generally quite a depressive person, and when I slide into one of those low states, a state that can only be described as decay (both physical and mental), then nothing can get me out for months. And let me tell you, its a pretty fucking slippery slope. So now every time I catch even the slightest whiff of lethargy (which for me is the tell tale symptom) I smack myself on the head and quickly go and do something. I don’t literally smack myself, but I instantly purge my mind and religiously take my own premeditated advice, laid out by myself, for myself, when I was in a more accountable state, and then follow it blindly; said advice being get up and go do something before its too late). Sometimes it is truly best to listen to others. This applies well here because I am genuinely a different person when I get depressed.

So, I suppose that herewith I am temporarily suspending this endeavour until the 25th of September, when I shall continue this (predictably named) “iPhone dev project”. I hope that so far you have found some use in these ramblings. Speaking of ramblings, I think I strayed off topic yet again. I did say though, right from the outset, that this would be slightly spoilt by my personal life. To quote Eddie Murphy, “if you don’t like it, you can get the !@#$ outta here”.

Speak soon, hope you’re well!

Day 4: C

Okay, so maybe I should have started with this first instead of with the OOP fundamentals. Today I spent about 3 hours learning C. I familiarised myself with the concept of pointers and how they are used to explicitly pass variables by reference, how they allow a function to manipulate and alter the parameters that were passed to it without needing to copy them, and the way they generally fit into C in terms of memory management. Structures were new too, which seem handy. The concept of header files and function prototypes is also new to me (coming from a Java background). One thing that struck me though, is how “dangerous” the C language is. It allows you to do all kinds of silly things, like e.g. fetching the 11th entry in an array that is only 10 entries long. “Allows” in the sense that the compiler does not complain (well it wouldn’t), but also that during runtime, no errors get thrown. With this in mind, probably the only thing that the C language “allows” (in the previous context) is for the programmer to be extremely cautious when using arrays, especially when it comes to nested loops and similar slightly more advanced tasks. Not only arrays need heed though, C memory management in general seems a bit like skating on a lake that only froze over yesterday. Predictably, I will be a bit uncomfortable when using arrays in double and triple loops in C; 9 times out of 10 it was the NullPointerException that used to come and brighten up my console when I used to (mis)program in Java. Ironically, it is right now brightening up my post editor as the spell checker nostalgically underlined it with a red dotted line… love it.

Today wasn’t a very productive day in terms of “Luka’s iPhone dev prjct” (the L in the logo stands for Luka in case you were wondering). Someone asked me for some help with advertising their house that they want to sell so that took some time. I also finally got around to fixing my windsurfing sail. I tore a hole in it a few weeks ago when coming out of the water, don’t ask me how because, I don’t know how I did it myself, and the monofilm repair kit that I ordered to fix it only arrived yesterday. That’s all right though because there hasn’t been almost any wind these last two weeks, and the forecast looks amazing for Sunday. The forecast wind is one that hasn’t blown–in terms of windsurfing proportions–all summer, yet it’s the highest forecast of the summer. It means I can go to a special spot that is characterised by very nice Caribbean-style turquoise, shallow water . I’ve never sailed my board there but I’ve sailed past by boat many times, the first time we almost hit the bottom, that’s how shallow it was. Which leads me to think there’s even a possibility of some breaking waves, which should be fun! On top of that, I’ve got a friend coming down, especially for Sunday’s wind, which is a 3 hour ferry for him (each way). It all came together perfectly, I could’t imagine a more majestic synthesis of events.

Pardon that digression, although if you’re a windsurfer I’m sure you can relate. If you aren’t let me just say this: windsurfers are a spiritual lot who deify the wind, to us, the wind is a highly beloved yet fickle and unpredictable god who is not afraid to inflict letdown, he is however equally kind, and on rare occasions he rewards our loyalty and perseverance with exceptional sailing conditions that then become the talk for many months to come-until that next epic day. Sunday promises to become one of those days.

Now, back on topic! I did not learn from “The C Programming Language” book as I said I would. I found a tutorial online that upon first inspection seemed to be even more concise than the book, and free, and was updated very recently, it contained specific instructions for a modern IDE, which so happened to be Xcode, which is what I will be using for developing on the Iphone… So I chose to study from there. I haven’t finished it but so far I can only recommend it. Looking to learn C on a Mac? Have a look on www.masters-of-the-void.com.

Damn, that post took about an hour and a half to write, and it contained almost no relevant information. Woops.

Luka

Day 2: Cocoa, iPhone, Xcode… nice to meet you

First things first, I might have underestimated the gravity of this endeavour. The way I saw things, I know Java so this was just a matter of picking up the new syntax, familiarising myself with the IDE, and off we go. Not quite. Just the Cocoa fundamentals is a 200 page read (I rounded that number down mind you), and then the iPhone App Programming guide is another 200 or so. And then still on top of that, Objective-C itself.

Needless to say, this was a reasonable assault on my morale, and a slight demotivation. And even though this might have been enough to send me straight back off to where I came from on most other occasions, fortunately for me, and unfortunately for the iPhone: I am persisting. I guess I could say that reality has barged down the door and has come storming in in all of its flamboyancy. Nothing like a cold shower though.

On a brighter note, I briefly acquainted myself with Xcode, downloaded some sample code, and got it running in the simulator. Pointless you might say, and I agree. It was futility disguised as progress though, and I gladly bought my own illusion. You see, seeing the iPhone up on my screen with something running inside it was necessary for keeping my spirits up.

Simulator first run

Simulator first run

Until the next episode…

Luka

Day 1: Downloading the SDK

Here we are, the cold beginnings. I’ve signed up as an Apple developer. My computer is downloading the SDK and my mind is wondering if this is gonna go anywhere.

I forgot to mention this in the introduction, but better late than never. Here’s what I have at my disposal:

Main programming machine will be a MacBook 13″ (unibody), 2 Ghz, 2 GB RAM. Screen is a little small I know, but it’s my only Mac so it will have to do. When I get “home” (I’m currently living in the UK, but at this moment I am on a 3 month holiday in Croatia) I can plug it into my 24″ monitor, which should make things a lot easier.

What I don’t have is: an iPhone, iPhone developer program subscription. You’re thinking “good luck sucker”… I’ll probably get an iPhone soon, and I will pay the program fee when I get some code working in the simulator, and am ready for testing.

Downloading the SDK is already a reasonable commitment for me because I am bandwidth limited to 10GB/month and the kit itself is just over 2GB. So thats a big chunk gone right off the bat (it’s the 1st today).

Current bandwidth usage

Current bandwidth usage

A little while longer and I can get the development environment set up, and hopefully start making some first attempts at objective-c development (hmm OCD for short, lame I know, but I just can’t help notice these things).

This is where we’re up to ATM…

Current SDK download progress

Current SDK download progress

I’ll keep you posted.

Luka

Follow

Get every new post delivered to your Inbox.