Integrating Facebook iPhone Connect
The new Facebook iPhone Connect API makes facebook integration very easy. Here is what I did to get the libaray compiled:
After downloading the Facebook iPhone Connection SDK,
1.Copy all .m and .h files under src to my project’s classes folder
2. Copy the FBConnect folder into my project’s root folder
3. Manually create the project FBConnect group in XCode
4. Manually drag all the files (2 sets) into the FBConnect group XCode
5. Compile and get like 170 errors
6. Go into project setting, in Header Search Path, click “+”, add the path “.” (Yes, just one dot)
7. Recompile and you should be fine.
iPhone Memory Management – Part II
More examples as I work through the project I’m reviewing:
Case: Auto-release on instance variables
When assigning to an instance variable, you should not set the object to autorelease. By having an instance variable means you want to ‘hold on’ to the object. And, make sure you do a release in the dealloc function for each instance variable that you have.
myObj = [[Obj alloc] init] retain]; //This is an instance variable
…
- (void)dealloc {
if (myObj) [myObj release];
[super dealloc];
}
Case: Assigning to properties
As a follow-up example, sometimes your instance variable are ‘linked’ as properties. If you set your instance variable through a property, you need to pay attention to your property attributes. If your property says retain, don’t retain again.
In ClientClass.c
….
Obj *myObj;
}
@property (nonatomic, retain) Obj *myObj;
…
In ClientClass.m
…
self.myObj = [[Obj alloc] init]; //No need to retain. The setMyObj function takes care of that.
iPhone Memory Management – Part 1
In review of a project today, I realize I need to write down some general rules on memory management around Objective-C.
I’m going to write more on this but here are some general rules:
Case 1. Setting properties.
Obj *obj = [[obj alloc] init];
myClient.obj = obj;
[obj release];
This assumes the property is either retain or copy. Either way, it’s the receiver’s responsibility to make sure the memory is being retained.
Case 2: Returning obj
- (Obj) foo{
Obj *obj = [[[Obj alloc] init] autorelease];
return obj;
}
When sending an obj as return, always set it to auto release. This is basically the same principle as “Clean up after yourself”.
Case 3: Array Manipulation
Sometimes you need to create a Mutable Array, populate it and return an Array. What I recommend is the following:
- (NSArray) foo{
NSMutableArray *tmpArray = [[NSMutableArray alloc] init];
… Build the array.. read from the database and populate it, etc.
NSArray *rtnArray = [NSArray ArraywithArray:tmpArray]; //This is an autorelease copy.
[tmpArray release];
return rtnArray;
That’s the basic cases I have in mind right now. I will continue to write as I come across them this weekend.
iPhone SDK Training
Since I started training my staffs on iPhone development, I thought may be it’s time to restart my teaching profession (I built a Java training school back in 2002). So we will start offering a 3-day crash course on everything iPhone soon. Here is the description:
================================================================
PD401 Jumpstart iPhone Development
Designed for people with prior programming experience such as C, C++, Java, C#, or Visual Basic, this compressed course provides a fast track to the iPhone SDK. Students will learn the basics in the Objective-C language and how to develop native applications for the iPhone and iPod Touch. Objective-C fundamental will be covered for students to quickly transfer their knowledge from other languages. Various iPhone SDK frameworks will be covered in details with hands-on examples.
Upon finishing this course, you will have a comprehensive understanding of all the major frameworks in the iPhone SDK and will be able to start developing on the iPhone platform immediately.
Note: Most iPhone training course on the market is a port from an existing Cocoa course for the Mac desktop platform. This course is built from the ground up with iPhone focus. The only goal is to let you being on this exciting platform as soon as possible.
At the end of the course, students will take home 4 complete fully functioning applications.
Framework covered:
- Core Location (GPS)
- Multi-touch Gesture
- Acceremormeter input
- Audio Recording
- Photo Capturing
- Quartz 2D graphics
- OpenGL 3D graphics
- Audio and Video
- SQLite
Class Outline:
Session 1: Objective-C, Cocoa, Coca-touch fundamentals. Objective-C classes, memory allocation, language conventions.
Session 2: Setup development certificate and mobile provisions for deploying on the device.
Session 3: Building View based application with Interface builder. Standard UI widgets. View Controllers and View transitions. iPhone UI design strategies.
Session 4: SQLite, UITableView and custom TableViewCell,
Session 5: Core Location, Google Map integration
Session 6: Server integration with HTTP, FTP. Integrate with Php and Ruby on Rails servers with XML-RPC.
Session 7: Multi-touch Gesture. Accelerometer input, shake and movement detection.
Session 8: Mutli-media. Audio and video, Audio Recording, Photo capturing
Session 9: Graphics. Quartz2D animation and OpenGL3D animation
Session 10: Prepare application for upload to the App Store and tips in dealing with the Apple approval process
=============================================================
iPhone development: Web or SDK
Came across an article from Ian Thain.
Web or SDK?
— Web Development and SDK Development each offer distinct advantages to the iPhone Developer…So I set out over the last two months, with the aid of the LinkedIn Polls feature to gauge the trend
I am a true believer of native application. After so many years of working on write-once-run-anywhere, I’ve come full circle (twice, actually) that if you want to develop for a particular platform, you should take advantage of all the features from a platform.
This is also why the iPhone come in late and now are far ahead of WindowsMobile. Windows has been in the mobile business for over 10 years and yet it failed to capture the market. Why? Because they tried to build an OS that will run on all the phones out there.
So now I take device agnostic very differently. As app developers, our goal is to provider users with the best experience. If I build a UI that will be ‘translated’ to different devices, the end result is that it doesn’t feel right in some device. For those who have done serious mobile web development, you will understand even web app will need to be tuned for each device, resolution, browser, OS, etc… So if someone tells you that you can develop the app once and it will work nicely on all platforms, either they are not telling the truth or the end result is not good.
That said, other than the UI, everything else should be platform neutral. Rather than trying to make the UI generic (which is impossible), we are creating a set of control functions that are common across all platforms, so device agnostic to us is common data (through XML), common behavior (through Restful webservices) and native UI.
Now am I saying everything should be native and never web? Of course not. web is great because it’s flexible, easy to develop, easy to deploy and provide real-time information to the users. Now when we design new app, we always starts with the final user experience, that always lead us to building native app with some web widgets inside for real-time dynamic updates.
Inauguration Report hits the App Store
Dave called me back to help out on the Inauguration Report project a week ago. I am so proud of the fact that I got to participate in the Twitter Vote Report project and now the Inauguration Report project.
This time you can report text, audio and photo. And also utilize offline storage so if cell coverage is affected during the Inauguration, reports can be submitted later.
Check out the App here:
http://www.zerionconsulting.com/inauguration_report.html
Download from App Store:
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=301986752&mt=8
Don’t forget to also checkout our game Rochabeau:
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=300203402&mt=8
Vote report iPhone app is official now!
Read Dave’s release note here.
http://votereport.pbwiki.com/iPhone-App
Proud to be part of the process!
Sze Wong
I’m now with the Twitter Votereport team
Yeah, it’s funny. I got an email yesterday (Sunday) afternoon saying that someone is in great need of some iPhone help and the deadline was mid-night!! When I got home I looked into the project and found out that it is the Twitter Votereport application. ‘Interesting’, I thought, and what is required is indeed something I can do. So I responded to the email saying I could help but it was already 6pm. A few email exchange confirmed that I will be helping out and there I was joining the team.
I end-up working form 10pm to 6am on it. Yes, all for democracy. (Hopfully Dave didn’t reject all my code and everybody can use it on election day)
Sze
Developers Hate J-RAT
One of my team member told me that she saw another team using our J-RAT method. I said “Great! How they like it.” “All developers hated it,” she said. “They didn’t like being watched and couldn’t actually code when sitting with everybody.” Well, that is a classic misuse of J-RAT. Every J-RAT sessions that I moderate have been loved by developers, testers and users a-like.
J-RAT stands for Joint Rapid Application Testing. It is meant to replace either functional testing or user acceptance testing. The goal of J-RAT is to change the testing culture from bug centric to product centric, and remove the wall between the test team and the development team. The idea is to set aside a period of time for testing a particular module(s) and all related parties (developer, testers, business analysts, end-users) in the project should all sit in the same room and focus on testing. One moderator will be assigned to the room (usually the test manager) who’s job is to control the pace of the test and how many concurrent threads are running within the room. The room should have at least 2 white boards and ideally 2 projectors. The development team should control one projector and the test team should control the other projector. The moderator will control one white board where test cases are written on the board and everybody in the room should know which case(s) are currently running. The other whiteboard is for discussion.
For a successful J-RAT, the moderator must be trained to run J-RAT and must be respected by the team. Since the moderator is pretty much the boss during J-RAT and if people don’t listen, the process will breakdown.
J-RAT also calls for no senior management in the room, preferably not even the project manager (except when it is for user acceptancce test, then the PM must be there), as the goal is for the team to freely express their concerns and thoughts to get the product out the door without worrying about ‘politics’.
J-RAT done right will result in dramatic reduced in testing duration (usually 1/5), higher overall quality and much high team spirit.
The team that my team member told me about probably saw us running a successful J-RAT session and want to replicate that. However, without proper training, all they have copied is ‘putting everybody in the same room’. The result is a crowded room with a senior manager in it; everybody is nervous, and not much got done.
Sze Wong
Zerion Consulting

