As all of us knows, location-aware services/applications are becoming more popular and widespread everyday. Especially, mobile devices play a very important role in that area. So we all, in some ways, need to access the location of a specific user of our app. Most of the mobile devices provides some hardware and APIs for letting application developers to access location services of the device. iPhone has a built-in GPS module and a framework is provided in Cocoa Touch called CoreLocation that is used for accessing location services of the device.
CoreLocation can be used to obtain the latitude and longitude parameters of the location of the device. But sometimes we need some more detailed information about that specific location. Country, city, state, street, may be postal code etc.. It depends on the application. That is something iPhone or iOS platform does not provide directly. However, we can use a web service such as Yahoo! PlaceFinder to access detailed information about a location of which we know the latitude and longitude parameters.
What SSLocationManager does is as follows:
- Ask CoreLocation services to determine current location of the device.
- Get current position in latitude and longitude from CoreLocation.
- Call Yahoo! PlaceFinder web service to get detailed information about the location specified with its latitude and longitude.
- Notify the application via SSLocationManagerDelegate and supply the detailed location data.
Here is a basic diagram that shows the overall structure:

SSLocationManager Diagram
Read more…
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…
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…