Life & Technology

Handful lessons in different areas of technology and life in general.

Tag Archives: iPhone

iOS Series: Recreating ABS-CBN News iPhone Application

With this iOS blog series, I will try to recreate existing application found on the AppStore that I assume is not natively developed in Objective-C codes but rather using 3rd party frameworks that produces/generates binaries specific to platform.

My target iOS application, ABS-CBN News is an iPhone-only application which I think is built using Titanium and a good candidate for this series for its simplicity. And we will try to examine components of this app and build our own from the extracted features. And also, we could try adding features not currently implemented if possible.

With this exercise, we will be exploring and using some popular opensource libraries to achieve our goals and to also help other developers who’s just starting in iOS development familiarize themselves to these awesome libraries.

On its core, ABS-CBN News has these features:
* A horizontal tab based menu for news category. Clicking each category will refresh the main table and lists all news focusing on that category.
* A live twitter feeds for @abscbnnews and its anchors and reporters. A read-only type view of individual tweets and no options to comment/public reply or even retweet the message.
* A settings page which the user can select what to appear on his/her “My News” category. User can also set total number of news per category. Maximum is 20.

This iOS Series blog post will be splitted into 3 parts:
Part 1: Building the basic UI components and defining its use.
Part 2: Creating Data Models and Consuming current REST Web Services
Part 3: Enhancing current features and adding/suggesting some.

Stay tuned for the first part of this series.


Horizontal Menu with UITableView Tap Status Bar not working

HorizMenu_ScreenshotYesterday, I downloaded the ABS-CBN News iOS app to see news and articles and let myself update on what’s going on. The application looks good and it feels natural, very intuitive as they presented their menus as a horizontal tab placed on the header and then the content is being changed on the UITableView. Even the UIView Activity Indicator on the bottom is non-intrusive and very well implemented.

But one thing I noticed, when I scroll news up to the bottom and scroll back on top by clicking the status bar, nothing happen, no matter how I try or select different tab, still it won’t work. And upon investigating, the problem is being caused by two UIScrollViews on the main view which prevents the UITableView from responding to scrollToTop.


As per Apple documentation:

 this is for the scroll to top gesture. by default, a single scroll visible scroll view with this flag set will get the call. if there is more than one visible with this
 flag set or the delegate method returns NO, the view isn't scrolled 
@property(nonatomic) BOOL  scrollsToTop;          // default is YES. if set, special gesture will scroll to top of view after consulting delegate

To fix the issue, I made a sample iOS application which uses the excellent opensource MKHorizMenu and use his demo application to add a UITableView and a logic that will check and set the scrollsToTop property to false if the UIScrollView implementation is not UITableView as seen below:

- (void)viewDidLoad
    self.items = [NSArray arrayWithObjects:@"Headlines", @"UK", @"International", @"Politics", @"Weather", @"Travel", @"Radio", @"Hollywood", @"Sports", @"Others", nil];    
    [self.horizMenu reloadData];

    [super viewDidLoad];
    self.title = @"Tap Status";
    for (UIView* v in [self.view subviews])
        if ([v isKindOfClass:[UIScrollView class]])
            if ([v isKindOfClass:[MKHorizMenu class]]) {
                ((UIScrollView *)v).scrollsToTop = NO;

Revised Demo application of MKHorizMenu is available for download here.

Hope this helps.

iOS: Parsing XML file using APXML Library

Recently, I just got the chance to work on an assignment that requires me to read XML file from the internet and display the fetch data on a simple UITableView. And to be honest, this is the first time I am parsing an XML documents as I am more familiar with the JSON format instead and JSON is fairly simple to work with on an iOS project using the great json-framework open-source library.

There are plenty of resources out there that will do the job very quickly and easily but I opted to try the clean and simple open-source library APXML that does exactly what I like to do – to parse an XML file with minimal effort.

First of all, I need to create a sample XML file which can be found here. This XML file  holds sample books with its title, price, authors and description on every node and has a single attribute that holds the bookId.

Content of our sample books.xml is like this:


Reading the XML file and place it in my NSString is pretty straightforward:


For simplicity, I just use ASCII encoding on line 6 but you can quickly change it to UTF if you need to. Just for the demo, this approach loads the XML synchronously and will block the main thread until the XML file has been loaded. And on line 11 is a private method that will call the APXML library to perform the actual parsing of the XML file like this:


With the above code, APDocument initializes with the given XML string and calls its rootElement to determine the root value which is the <catalog> in order tor the parser to determine the object for which it can get all the childElements under it. Child elements is an NSArray of APElement which we can iterate until the last <book> node is read.

APXML library gives you simple method call to get the attribute name:

   1: [child valueForAttributeNamed:@"id"]

Or getting the value of each element in a given node (<book>):

   1: NSLog(@"Author: %@", [[subElements objectAtIndex:0] value]);

After the method parseBooks has been executed, the usual UITableView will fill-up all the books from our dictionary:


And if you click on each cell, we can display the details of the book with our UIAlertView:


The output of our test project is something like below:

xml_21  xml_22

Haven’t tried other XML libraries for iOS yet, but I’m sure APXML will do most of the job on parsing XML file. You could try this cool library also!

iPhone: NSDate as Double and vice versa

If you’re parsing JSON result from a webservice that returns date as double value and you like to display the human readable date formatted NSDate, one possible method we could achieve this is by using NSDate dateWithTimeIntervalSince1970. As our example below, we like to convert the value of “exp” from Double and vice versa.


Parsing this in Objective-C is pretty straightforward and you only need NSDate class for the conversion.


And when we run it via SImulator, we can see similar result here:

iPhone Simulator

Simple and useful.

Reference: NSDate Class Reference

iPhone 3GS: Lifting its firmware to iOS 4.0

iOS 4.0Recently, I had a chance to upgrade my iPhone 3GS OS to the new and latest iOS 4.0.1 and my experience with this new firmware is quite impressive and enjoyable on my part.

At first, I just plan an upgrade but opted a fresh clean install of the firmware so I choose the Restore facility available on the iTunes. So the iTunes downloaded first the firmware before proceeding to the actual installation of the new firmware. During restoration, I did encounter a problem during iPhone Software Restore stage, it just stops about 98% and the progress bar on my device was not moving. So during this state, I research Apple documentation for a possible solution but the only solution I got is that I should repeat the process again because the device will automatically enter in the DFU mode. I did try the restoration process for about 3 times but still no luck using my MacBook Pro. Luckily, I still have another machine, a Windows 7 machine for me to restore my iPhone 3GS, so I repeat the process of downloading the iOS 4.0.1 on the windows machine and surprisingly, the installation went smoothly with no errors whatsoever! This time, my windows box saved my day!

iOS 4 Observation and Experiences

Feeling excited about this new iOS 4 on my 3GS, I explore the new features that made this new firmware awesome and cool!

These are the items I just noticed and experience that has an impact to my day to day usage:

This feature is rock solid! Now all my iOS 4 native applications installed on the device can now run in the background and updates itself when presented again in the foreground. Twitter and Facebook for example employs the multitasking feature. And also, Soosiz, a platformer game which is one of my daughter’s favorite already updated to be iOS 4 native!

Safari Address completion
Though, this is a minor one but still a really nice update. Now, if you’re typing a website on the address bar, the dropdown list of all currently cached sites will be displayed in a Website Name + URL context which in turn makes it easy for users to know what name the URL is he/she visiting. This feature is not found on my iPhone 3GS.

Location Services
With iOS 4, the user now knows what applications are using the GPS functionality and you now have the ability to turn off GPS function on a per application basis. This can be done via the Settings Menu/General/Location Services. Before, the only way to refresh the GPS Permission popup, you will need to reset the Location Warnings and open the GPS-aware application again to prompt the GSP Warning message.

And its good to note that the GPS functionality sports a new icon placed before your battery information on the upper right of the screen which basically notify you that your currently opened app is permitted to use your GPS information.

Spotlight Search
With 3GS, spotlight search will basically crawl all data available to your device, be it Email, SMS, Contacts, Applications, etc. Now, we can actually filter out sections that the Spotlight will search for an item. And this settings is located under your Settings/General/Spotlight Search

Message Counter
This feature is already available to a jailbroken iPhone via an app download to the Cydia repository. And i think that Apple sees that this little feature will be very very useful in order for user to know the actual SMS count (because money counts if you’re a prepaid subscriber!).

But this setting is turned off by default, to enable message counter, you just need to go in Settings / Messages and swipe the Character Count to On.

I’m not fond of changing wallpaper to my device, I am always contented with simple and defaulted background of the device. But with this addition, the user can now set/change the homescreen and springboard background image as a separate or as same for both. With me playing around with this, I find all the default installed backgrounds to be simple and nicely done effect that is very very elegant to view together with icons.

Threaded Mail + Picture
Yes, at last, I don’t have to scroll down and down to a single threaded message to actually read the previous conversation! With this feature, the front view of your inbox will have a number badge if the message is threaded and when opening a threaded email, it will list all messages as a separate cell allowing you to choose which one do you like to read and scroll thru the bottom to read just for that specific message! Very clever and great feature!

Not only this, if you open an email whose sender is part of your contact (provided that you include the contacts’ email address) and your contact has a photo, it will automatically display the photo of your currently selected sender. So while reading his/her message, you have a visual of who’s sending you so that you can read the message with feelings or not! =)

I know that many people is expecting this feature so I will not talk about much about it. All I can say that they done a great job in implementing Folders to categorize your applications. Apple did a clever job in identifying the initial name of the folder if you first try to drag the application to another app. For most of my folders, Apple’s suggestion is always my first choice!

And what’s nice about the Folders is when you try to download an upgrade for your app that is inside your folder, Apple nicely displays the progress bar INSIDE your folder and not in the folder itself! How cool is that!

Camera Zoom + Speed
This feature is greatly improved with regards to the speed in taking a shot. Before, if you take a single shot, it will have a shutter delay for about a minute but now, the shutter will close at a blink of my eye and the image is saved instantly!

And with camera zooming now integrated to the Camera app, I don’t think I will be purchasing an app that have the same functionality.

Notes / Calendar
Now, this native apps have a syncing capability to your email account like Gmail. Like for instance, in the Notes app, if you create a New Note under your email, it will automatically sync to your GMail and you will see it in real time as a new section called Note. Same goes for your Calendar!

These changes will soon be updated to allow a 2-way syncing of items. I hope so. 🙂

I am a Mac user currently using Snow Leopard OS and loving the iLife 09 especially the Photo application which basically let me tag images with Faces and Places.

With iOS 4, this is now possible! Well, at least for the Places part :). Before, I am taking shots and not knowing instantly the location the photo is taken, I have to sync it first to my MacBook and let the iPhoto do the geo-tagging. But now, it’s already built-in and part of the Photo app on my iPhone. The app now has a 2 tabs, Photos and Places which will do the geo-tagging for me to all available photos I have that has a geo tag information embedded on it.

So far, with the new features and functionalities this new iOS 4 introduces to the users, I am very happy with all of the new and updated changes!

So, if you own an iPhone 3GS, iOS 4 is definitely a must try!

Fixing GPS (Stops Working) Issue on iPhone 3GS

While working and debugging my XCode project that involves reading of Users’ Current Location (GPS), I just noticed that when I run the application on to my Device (iPhone 3GS 3.1.2), it didn’t ask for permission to Allow Current Location. and I thought I was doing something wrong with my code. So I looked back and tried running it on iPhone Simulator, the code works and it did catch the defaulted Current Location on the Simulator. Then I restarted my device to make sure everything is on the init state. I opened the Compass application, and it read 0 degress N and the Locate button on the lower left is disabled!

With this encounter on my device, I started other applications installed on my phone that accesses my GPS and none of them worked! Naturally, I suspected that my iPhones’ GPS suddenly died on me. Through this, I started firing up Firefox and start googling looking for someone who has the same case bout me and a solution for the problem.

Solution #1: Resetting Network Settings
It said that by resetting the Network Settings on my iPhone will fix the issue. So I reset my settings through Settings/General/Reset/Reset Network Settings and my device restarted itself.

This solution didn’t worked for me but it did work on most iPhone 3G models.

I keep on searching and found the most reliable solution that involves opening an SSH on my device. So, I’m sharing what I did below:

Solution #2: Issuing commands on SSH Terminal
This solution will only work on a Jailbroken iPhone as it needs to be able to connect via SSH.

1. Connect to SSH by using Putty on Windows.
2. Login as root (default password is alpine)
3. Type killall –9 locationd and press Enter. This will signal to kill a process called locationd (the daemon that GPS use).
4. Type rm -rf /var/root/Library/Caches/locationd .This will remove all available cache under the locationd directory which in this case is the cache.plist. You can also delete just the cache.plist if you like.
5.  Open up Compass application again the the alert popup will display asking for a permission to use your Current Location.

Solution #2 accurately fixed my GPS issue and I didn’t even need to restore my iPhone from my backup! This approach saved my day and I recommend doing the same thing if the problem will occur on your precious iPhone 3GS.

Enter iPhone 3GS. A New Level of Experience.

Finally, I owned the fastest, most powerful iPhone yet – the iPhone 3GS 32GB.

I’d like to thank Globe Telecom PH for their speedy process (IMO) on their iPhone reservation. I did file an online iphone reservation on their site and after 2 days, walked to a nearest Globe center in Robinsons Galleria and file the reservation form for Plan 899. And the customer service representative named Marvin, who attended my inquiry said that I will expect a call after two weeks from the time of my sign-up, so roughly 2nd week of August 2009. And weeks passed by until last Friday, Marvin being lucky enough to be true to his word called up at my office and said that my unit is now available and can drop by anytime on their shop. Whew! what a nice weekend for me to finally get a hold of an iPhone, my very first time to literally touch this device!

So what’s the content of the package? Simple – An iPhone 3GS small box colored black and a black unit, a post-paid SIM card which is not yet activated and an iPhone 3GS paper bag.

So …

What I learned/discovered so far?
* …that the camera resolution is 2048×1024 in 3megapixel. But if you’re sending the image via the Send Photo, it will actually trimmed down to 800×600 resolution. To get the actual size on sending the photo, just open the photo, copy it and paste it on your email client, Presto! original file size and resolution will be sent!
* … that since my location is Philippines, if I detached my iPhone from iTunes PC and leave the location as is, the iTunes via iPhone will not work anymore, I can’t even open the main window to search for music! Error message says that my location is not supported! My only resolution to this problem is if I like to browse the iTunes on the phone, just change the location to United States and sync this info to my iphone. This will solve the iTunes problem but using this settings you cannot install any application from AppStore. So, just vice versa, leave it as is for your original location if you like to install an App via AppStore on your phone.
* … that to arrange my apps / icons, just tap and hold the screen until the icons start shaking indicating that you can now drag-n-drop icons into different places to your liking. Very slick and well-thought design!
* … that iPhone do not work seamlessly with a Wireless WEP connection on my Linksys router. I adjusted my security setting and moved it up to use the WPA2-Personal security type. No problems so far after this changes.
* … that the SIM activation is a 24-hour period and the iPhone needs to be restarted in order for the carrier to detect/refresh properly.
* … that installing an app on both PC and iPhone is the same, simple and intuitive.
* … that the iPhone 3GS Guided Tour video is true and all of the features are wonderful and useful.

What I recently purchased?
* Currently, out of curiosity, just bought the app for my daughter called Old McDonald via AppStore on my PC that costs $ 0.99. My daughter, Margrette, is very very happy on this app coz it allows her to choose from the list of animals that fit on McDonald’s farm. Simple yet effective and entertaining for kids.
* Purchased my Belkin iPhone cover for Php 1,200 at PowerMac Megamall and a CapDase screen protector worth Php 450.00 at digital Hub Robinsons Galleria.

What I already installed?
* TweetDeck – Being my default twitter desktop application on my Windows XP laptop, it’s natural for me to install this app on my iPhone since I am familiar with the interface, nothing changed, except the size. I really really like TweetDeck and considered as my top favorite for client product line for Twitter.
* 12cast – I find this app very useful as it allowed me to upload my videos and directly post the link as my twitter status! Very clever.
* TapTap Revenge – I’m starting to get myself addicted to this FREE game. Just like a Dance Revolution but using your hands instead of feet. Very very entertaining and makes my hands keep alive and functioning (arthritis safe?). What’s more cool to this app is the ability for me to choose my tracks or just download all available free tracks.
* Y! Music – Since I don’t find yet a Radio app to play radio songs, this app makes me listen to all kind of songs except that no Tagalog songs.
* Yahoo Messenger – Need to say more?
* Facebook – Even though I don’t have a facebook account yet, but soon I will, for now, only my wife is using this.
* AppGmail – The default Mail of iPhone allows me to add my GMail account but this one is cool in that it allows you to read mails fullscreen and more.
* FreeRSS – My RSS reader of choice or maybe I didn’t search for alternative?
* SabiNila – This app was created by a Filipino company, Vinta and caters all local news headlines, politics, business, technology, world and others powered by I salute the developers of this app, makes myself proud to be a Filipino by delivering their title name in Tagalog and even the background is the 3-stars of Philippine Flag.
* ZZips PH – created by developers that caters a quick lookup of all zip codes and location in the Philippines. Graphics is simple yet attracted. Cool app!
* Others – mostly games and education related for my daughter.

What I like to do next?
* … maybe purchased more apps with $0.99 price tag on it! Doesn’t cost that much.
* … to Jailbreak/Unlock my iPhone before Christmas. Still need to get my hands around this device for a couple of months.
* … explore more on this device via programming utilizing the iPhone SDK which I already downloaded but not yet started on it. There’s a learning curve on this as I’m not yet very familiar with Cocoa Objective C language. Had a glanced on it but never really had the time to try it.

So, where’s your sample shots?

powermac_belkin iphone_babyandgreta iphone_greta iphone_greta_chair

Where’s the sample videos?
My video samples will be uploaded via 12cast and can be seen via my twitter status updates!

iPhone 3GS is my latest expensive gadget so far! And currently satisfied with it and starting to love every piece of information available on the iPhone 3GS. And I must say IMHO that although some people can afford this phone, this device is not for everyone. If you like this phone just for the sake of having it, forget it, this phone have so many things to offer if you truly believe that the cost of this unit is more than the cost of what you’ll gained.

Truly, a new level of experience is starting …