I gave a lecture on “iPhone Development” at Kadir Has University on April 26, as a guest lecturer. Here is the demo application I wrote for the lecture:
https://github.com/ardalahmet/TwitterSearchApp
It really is a simple application. It allows user to enter some text and search it on Twitter and shows results in a UITableView. It basicly demonstrates how to consume a JSON web service and how to use common UI views(UITextField, UITableview).
Git readonly url:
git://github.com/ardalahmet/TwitterSearchApp.git
Read more…
iOS family has become a very attractive gaming platform since the first release of the iPhone. iPhone platform both attracts game enthusiasts and game developers for many reasons. There are a lot to mention but to name a few;
- iPhone is mobile: You carry it wherever you go. It doesn’t matter whether you’re resting at home in the evening or you’re waiting your plane to arrive at the airport. Your little baby is in your pocket whenever and wherever you need it.
- iPhone provides a natural user interface: You can use your fingers as if you do in real world. You can swipe, multi-touch, drag, throw, catch and hold things in games. You don’t need a joystick or a complicated control device to interact with the game. The screen is there and you have the control with the touch of your hands.
- iPhone is compact and handy: Phone, music, productivity and entertainment… All in one device. You don’t need a separate device to enjoy your favourite games. And you don’t have to have hours of free time to play a game, even a 5 minutes of spare time while you wait for the metro at a station is sufficient for most of the games to play.
- App Store is a heaven for both iPhone users and developers: There are literally thousands of games in the App Store. Ranging from simple time-killer games to very complicated, rich graphics, multi-user games… You are both able to find your favourite childhood games and also discover many new games with a lot of innovative, surprising ideas and features. And for developers, it’s really a heaven. Imagine your simple, weekend-hack game is being listed with the games of the industry giants such as EA Games, Sega and many others. It was nothing more than a dream a couple of years ago, isn’t it?
Read more…
I gave a seminar on “Introduction to iPhone Development” at Kadir Has University on March 24. Here is the demo application I wrote during the seminar:
https://github.com/ardalahmet/ToDoListApp
It doesn’t do anything useful but just demonstrates some uses of common cocoa touch UI elements, some fundamental objective-c data types and basic persistence.
Git readonly url:
git://github.com/ardalahmet/ToDoListApp.git
Read more…
We all know about and use the well known -(void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated method of the UIViewController class, right? It does well for most of the cases, especially for displaying temporary view controllers for a limited task. We present them, they do what they’re expected to do, and we dismiss them when we’re done. An example might be a view that gets some login credentials from the user and passes those to its delegate and dismisses. But, what if we want to present a relatively smaller view, without covering the complete device screen and we also want it to be shown in a modal manner, that is, somewhat disabling the visual and functional interaction with what is behind the view for a while.
This demo project shows one of the many possible ways to do it, just to give an idea on the topic. What I implemented here is a class named ModalBoxView. It is the view to be shown modally. It supports both portrait and landscape interface orientations. Instead of trying to describe what it’s like, here it is:

A screenshot in landscape mode
Read more…
Remember how the navigation bar of Apple’s Notes application looks on iPhone? It doesn’t look like one of the system provided styles for navigation bar, neither UIBarStyleDefault nor UIBarStyleBlack. And it also looks nice and elegant, doesn’t it?
It, sometimes, would be nice to be able to change the background of the navigation bar and the color of navigation bar buttons as well. There are several ways for changing the background view of the navigation bar, one is inserting a UIImageView as a subview to the UINavigationBar at index 0. But i found this method to be a bit problematic when it comes to adapt the background view when the device interface orientation changes. Instead i create a UINavigationBar category class and override the default behaviour of the -(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context method. This alters the appearance of all UINavigationBar instances in an application-wide manner and this may be something you don’t want in some cases. However, it is really not so much difficult to use the same technique and change the appearance of UINavigationBars for individual instances. What we’ve done here may also be useful in the case you want to implement a visual theming system for your application. By dynamically changing the images we use as background, it’s possible to make UINavigationBars look different with different themes your application provides.
Read more…
While developing apps for iOS devices, we, in some cases, need to load some remote resources asynchronously in background without making the main thread and the UI become unresponsive. This demo project explains loading images from the web but the same technique could be applied for loading any type of resources, i.e.: audio files, text files, mail headers… to name a few. There are several possible approaches for implementing background loading in Cocoa Touch. All are based on the same simple principle: perform resource loading tasks on some other thread(s) other than the main/UI thread and make UI updates(if any needed) on main thread. There are two nice classes in Cocoa Touch framework which I used for this demo project: NSOperationQueue and NSInvocationOperation. Although NSOperationQueue provides some other complex features, what we simply need here is just:
- Create an NSOperationQueue object,
- Create NSInvocationOperation objects with target, selector and task data(in our case this is the image url)
- Add the NSInvocationOperation object to the NSOperationQueue we created
- Run the operation queue to process queued operations(in our case, an operation is to download an image from the internet)
- If there is need for any updates on the UI after a task is processed, i.e. an image is downloaded, perform those updates on the main thread by calling one of the performSelectorOnMainThread methods of the NSObject class.
That’s all it simply takes. Now time to show some parts of the code (which i consider worthwhile to have a look at). I believe the code is self-explanatory enough to be understood without any further explanation on what it does.
Read more…