Saturday, March 10, 2012

How to generate NSManagedObject files for each entity from the model files using CoreData

1) Select the entity, e.g. Person
2) Show the data model inspector (Option-Command-3) and change the Class field to "Person" [Fig. 1]
3) With the entity still selected, select "New File->Core Data->NSManagedObject subclass" [Fig. 2]
4) Click Create button
5) Two files, Person.h and Person.m will be created automatically for you

Fig. 1

Fig. 2

Saturday, January 15, 2011

Facebook Connect on IPhone - Part 1

Tried a bit of Facebook Connect IPhone App programming today which didn't go as successful as I hope because I was initially confused by two sets of Facebook Connect APIs which are currently available.

The older version released prior to Dec 2010 which is explained by tutorials such as this:
http://www.mobisoftinfotech.com/blog/iphone/iphone-fbconnect-facebook-connect-tutorial/

The LATEST version, released in Dec 2010 available here
https://github.com/facebook/facebook-ios-sdk

It's always better to work with the latest version,  so without hesitation, I went for the second version.

Fortunately, there was a step-by-step guide for that API, so I thought it would be a breeze to get started if I just followed the steps as explained in the guide.

Step 1 looked deceivingly easy.  Install the GIT installler, and use the software to download the latest version of the Facebook Connect build.  But ended up, it wasn't so! Well, downloading it was the easiest part.  I did so at the Google page here: GIT installer Page.  Since I was on a Macbook Air (2010 version) with Mac OS 10.6.5, I chose the version right on top: "git-1.7.3.5-i386-leopard.dmg".

After that, I just double clicked the DMG to install it, and thought I can quickly get started to download the code by looking for the application in "/usr/local/git/bin" which was supposed to be the default path the application will be kept.  Navigated to the folder, but couldn't find it :(

Navigated to other possible folders.  Still couldn't find git.  SPOTLIGHT couldnt find it either.  It only managed to find the DMG file I downloaded! Wasted at least 30 minutes doing this before I gave up and decided on the more practical solution.

What I ended up doing was to open up a Terminal window with SPOTLIGHT, type "git https://github.com/facebook/facebook-ios-sdk.git" at the command-line, and lo-and-behold, the SDK was instantly downloaded to my Documents folder. Phew. Finally.

What came after that is a LOONG story, but happy to say, after countless debugging, I managed to successfully to do a login to Facebook as shown in the screens below.

I will be sharing some snippets of code in my next few posts as I get more familiar with this API but meanwhile, if you are interested, here are some good links to follow:

http://thinkdiff.net/facebook/how-to-develop-facebook-application-for-iphone/
Facebook Graph API : http://developers.facebook.com/docs/reference/api/


Initial appearance

Facebook Login screen is automatically shown when the prev button is clicked

Your permission will be sought to authorize the App

The status is shown as "Logged in" and a button "Get User Info" is added

The label is updated to display user name when the "Get User Info" button is clicked

Friday, January 14, 2011

My first independent IPhone app!

Tried programming a simple IPhone app all on my own since yesterday, and I feel quite accomplished and satisfied because I managed to come up with something that works pretty decently ^.^

Started off with a "TabBar" template and modified it until it looks like this.

What I practised while coding this application was:
1) <UITableViewDataSource,UITableViewDelegate>
2) How to connect UIViewController to View objects
3) How to load a web image into a UIImageView

It was fun! :)

First View when app is loaded. User can click on any of the rows. Uses UITableView

Displays an image loaded from web

Wednesday, January 12, 2011

NSURLConnection - failed

Tried out some NSURLConnection programming today, but didn't succeed.

So this project will have to continue tomorrow perhaps.  

Anyway, keeping these links in hand in case I may need them later

NSURLConnection @ Apple Developer
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

Dynamically update your IPhone from TouchCode Magazine
http://www.touch-code-magazine.com/update-dynamically-your-iphone-app-with-new-content/

Adding Local Weather Conditions To Your App
http://icodeblog.com/2010/09/03/adding-local-weather-conditions-to-your-app-part-12-implementing-corelocation/

Sunday, January 9, 2011

7th, 8th and 9th IPhone App - Utility App, TableView with image, Indexing and Searching in a Table View

Did three more practice apps by following the instructions in Chapters 9 and 10 in Wei Meng's book again.

UtilityApp Template - Allows us to quickly create applications that can switch to a different view.  Wei Meng's example also teaches the reader how to add a TABBAR item (+ button as seen in the screenshot below)

Utility App (The default template does not have the + button, the book teaches you to add it and to perform action when it is clicked)



TableView

I learnt how to
Add items to a Table view
Allow users to select rows in a Table view
Add images to rows in a Table view
Group items in a Table view in sections
Add an index to a Table view
Implement a search in a Table view
Add disclosure and checkmark images to a row in a Table view

TableView populated by a Property List, with image

TableView organised in sections, with index on right and search bar on top

Saturday, January 8, 2011

FIFTH AND SIXTH IPHONE APPLICATION - TabBar App, Navigation-based Application

Did two more apps by following Wei-Meng's book (Chapter 8) which use the TabBar and Navigation Based templates respectively.

Starting to get the hang of IPhone app programming ^.^

Navigiation-based App, selecting an item allows us to switch to another view

TabBar App

Friday, January 7, 2011

Fourth IPhone Application - UIViewController

Today, I learnt how to implement multiple views using the UIViewController by reading Chapter 7 of "Beginning iPhone SDK Programming with Objective-C
by Wei-Meng Lee"
.

In this chapter, Wei-Meng teaches the reader how to create a Window-based IPhone application creating a UIViewController that maps a View to a Window in two ways, using the Interface builder and using programming code.

The reader is also taught how to switch between two views as shown in my screenshots here. I took an entire morning to try out the code, as I kept missing steps here and there, but the feeling of accomplishment after seeing it run in the IPhone simulator makes me forget about my earlier anguish each time! ^.^

Initial appearance of application

Switches to this view when the "Ok" button in the first screen is clicked.
Conversely, will switch back to "Second View" when the "Click" button is clicked