Category Archives: iOS Programming

Rapid Prototyping with Xcode Storyboard

Recently I wanted to rapid prototype a working application and show it to my team to understand the user flow. The options I had to do this was to use a HTML prototyping. Since I was learning Xcode and Objective C, I was curious to try out Xcode. I was impressed.

The use case is I wanted to build hierarchy of List of Category => List of Manufacturers => List of Brands => List of Model within the brands. Each these objects will have a set of attributes that the user can update.

In Xcode we will create a Tabbed Application and include the Storyboard option. We can target this application for iPad for better screen layout.

The front page looks as below,

From the storyboard enable Detail Disclosure and connect this ViewController to the next ViewController by dragging from the “>” to the next ViewController.

The code to populate the default value is below,

- (void)viewDidLoad

[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.myTableView.delegate = self;
self.myTableView.dataSource = self;
self.colorNames = [[NSArray alloc]
initWithObjects:@"Car", @"Video Console", @"SmartPhone", @"Phone", @"Camera", @"LED", nil];

Implementing Back button,

Rapid Prototyping, Back button

You can connect the “Back” button to “action” in the .h file. The code to make the Back button work is as below,

[self dismissViewControllerAnimated:NO completion:nil];


If you notice that we can built a medium complex application prototype Rapidly using Xcode.

I hope this blog helped you.

Sample iPad app to work with JSon based Machine Learning System

For people in hurry get the iPad app Sample code and steps to run here.

GoSmarter is a JSon based Machine Learning System, to which, if you pass a Natural Language (NLP) Query, it will return a list of recommended products, primarily Used cars, Electronic Gadgets,  Video Consoles and others. This Machine Learning also uses Social networking capabilities to recommend products based on your friends.

In this sample, I have written a iPad based application, which is a 2 tabbed application, in the first tab, it will return all the popular items among GoSmarter user base. In the tab 2, we can pass any query and it will return list of products that are current from Amazon, eBay and other sources. Some of the iOS Programming capabilities it demonstrate are,

As a starter in Xcode it is easy to create a Tabbed Application with Default Storyboard with 2 Tabs. While creating the project, you just have to tell Xcode this application is better configured for iPad.

Refer this youtube Searchbar samples by iffytheperfect1983, In our sample, we got the query from the Searchbar and passed to GoSmarter JSon RESTful API Code is as below,

-(void)loadData: (NSString *)searchString {
NSString *baseUrlString = @"";
NSString* escapedUrlString = [searchString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString *urlString = [baseUrlString stringByAppendingString:escapedUrlString];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];

webData = [[NSMutableData alloc]init];
[self.myTableView resignFirstResponder];

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
NSString *searchQuery = searchBar.text;
[self loadData:searchQuery];

There is a good youtube demo for sharing data between 2 applications by iffytheperfect1983, there is also a good blog Storyboards Segue Tutorial: Pass Data Between View Controllers. These 2 show how to share data between 2 View Controllers. In our sample, the usecase is, when user selects a popular item, it should pass this query to the 2nd Tab View Controller and it should automatically return all the results in that query. UI is as below,

Storyboard Segue UI for sharing data between View Controller

Storyboard Segue UI for sharing data between View Controller

//First View Controller:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
SecondViewController *viewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.myTableView indexPathForSelectedRow];
viewController.onLoad = YES;
viewController.searchString = [nameArray objectAtIndex:indexPath.row];

//Second View Controller</pre>
- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self loadData:searchString];

There is a youtube video on creating Custom Table View Cell. We created a Custom TableView cell and associated with 2 Label one for Name and another for Price as below,

Custom UITableViewCell

Custom UITableViewCell

The code for Custom Cell,

@interface CustomTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *label1;
@property (weak, nonatomic) IBOutlet UILabel *label2;

To conclude in this sample, we demonstrated some of the fundamental capabilities of iOS Programming. 

You can also tryout NLP queries in this Machine Learning system as we have defined Product Ontology,

  • iPod below $25
  • Mario < $25
  • Mario > $25
  • Mario less than $25
  • iPad greater than $250
  • Car near 01702
  • Toys for boys, Toys for girls
  • Mobile phones for old people
  • “42” LED
  • Low cost Smartphones
  • Cheap Phones
  • New LED
  • Samsung: will return Samsung Smartphone, because in Product Ontology, brand identification for Samsung is Smartphone

iOS Programming using Xcode IDE and Objective C: My take

For people in hurry get the latest code and open this example in Xcode IDE and run the example.

In my 22 yrs, all along I have been either a Microsoft technology programmer or a Java programmer. I always wanted to understand “the dark side” of application development, iOS Programming using Xcode IDE and Objective C. iOS Programming is all about Programming for iPad and iPhone class of devices. This weekend, I had an opportunity to tryout few things,

  • How can you compare Xcode IDE to something like Eclipse or Visual Studio? Are there any build tools like Ant or Maven in this part of the world? Are there any tools for Dependency management similar to Maven repository?
  • How similar or different is Objective C compared to Java or C++

After trying out, my opinion has changed about iOS programming. I really started liking it. As with any tools, there is a learning curve. Once you get past it, it is cool. Xcode IDE is very well integrated with iPhone/iPad simulators.

If you want to start development, as a prerequisite, we need a Mac system and you need to download Xcode. If you want to upload your applications in App Store you need to signup for $99 iOS developer program. This will also get you ton of goodies like Beta tools you can try out.

Xcode: My take

My couple of days experience with Xcode, I started liking it. For a starter, there are few tutorials on youtube from iffytheperfect1983, please try out these and you will quickly get a grasp of Xcode, Objective C, Cocoa, Cocoa Touch. Cocoa framework is used to develop OS X applications and Cocoa Touch is used to develop iPad/iPhone based application. I tried JSon Parsing tutorial, SQLite tutorial and Grand Central Dispatch tutorial and liked all of them. There is also a Basic Calculator tutorial, you will like it. I suggest, open your Xcode and work along these tutorials, you will quickly get a hang of Xcode and Objective C. Xcode also has SenTest a good unit testing framework, I haven’t explored it yet.

Xcodebuild: My take

There is a materials on the web that talks about Xcodebuild and CocoaPod. I tried Xcodebuild, this is similar to ant. They say CocoaPod is a dependency management tool similar to Maven. I haven’t tried it, in my next few blogs I will try and let you know. To run a simple xcodebuild command on a Xcode project you need to type in below command,


Objective C: My take

This language looks very convoluted at first glance, but if someone knows C, they can pick this up. Reading through the web, it is clear Apple team consciously took decision to go with Objective C. Someone also spoke about Objective C philosophy. Someone compared C++ with Objective C.

Sample JSon Rendering application for iPhone

This is a simple example, where when we click a button, it will get the RSS feed of top 10 albums and bind it to a table view. The JSon structure looks as below,

iOS Programming using Xcode IDE and Objective C: JSon Rendering exercise

JSon structure to be used for iPhone/xcode application

The code sample is as below,

-(void)connectionDidFinishLoading:(NSURLConnection *)connection{

NSDictionary *allDataDictionary = [NSJSONSerialization JSONObjectWithData:webData options:0 error:nil];

NSDictionary *feed = [allDataDictionary objectForKey:@"feed"];

NSArray *arrayOfEntry = [feed objectForKey:@"entry"];

for (NSDictionary *dictionary in arrayOfEntry) {

NSDictionary *title = [dictionary objectForKey:@"title"];

NSString *label = [title objectForKey:@"label"];

[array addObject:label];


[[self myTableView]reloadData];


- (IBAction)getTop10AlbumButton:(id)sender {

[array removeAllObjects];

NSURL *url = [NSURL URLWithString:@""];

NSURLRequest * request = [NSURLRequest requestWithURL:url];

connection = [NSURLConnection connectionWithRequest:request delegate:self];

webData = [[NSMutableData alloc]init];

For more details, import my project into Xcode and run the example and understand the code flow.

I hope this example helped.