Vote Report Wins the Golden Dot Award
Yesterday I went to the Politics Online Conference in Washington D.C. for the Golen Dot Award. Since so many of my friends ask “What is that?”, I’m going to talk a bit about the project and the award itself. I will then post a follow-up blog on my experience yesterday in more detail.
The award is the Golden Dot Award from the Institute for Politics, Democracy, & the Internet at George Washington University. Every year, they organize the PoliticsOnline Conference in Washinton D.C. and announce the best internet projects related to politics. This year, our project, the TweeterVoteReport and Inauguration Report, won the Best Mashup category.
The projects, VoteReport and InaugurationReport, are Crowdsourcing Political Journalism projects. In plain English, it’s using social network technology and allows the public to document political events. During last year’s election and the inauguration in Jan, we use the same technology and allow people to share their experience. The result is huge amount of data (text report, photo, audio, video) with geo location information. We collect data through Twitter, SMS, Filckr, Youtube, iPhone and Android. We then open up this stream of data and allow any media outlet to mashup in anyway they want. The project is completly open-source. The project was organized by NPR, Tech President, American Univeristy and CBS News. There are over 20 developers participated in these projects, including Sanford Dickert from Contagious Conversations, Dave Troy from TwitterVision, Andrew Turner from GeoCommons, Sze Wong from Zerion Software, and Nathan Freitas. Full contributor list of the vote report project can be found here.
You can read more about the projects in my pervious blogs or the following links:
http://techpresident.com/blog-entry/vote-report-wins-golden-dot
http://afine2.wordpress.com/2009/04/13/twitter-vote-report-goes-to-india/
http://blog.twittervotereport.com/
http://www.npr.org/blogs/inside/2009/01/inauguration_report_is_live.html
http://www.npr.org/templates/story/story.php?storyId=99395388
http://www.inaugurationreport.com/
Like I said on the Panel yesterday, it’s been a great honor working on this project. From both the social data collection and development collaboration perspectives, this project was a great success.
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
=============================================================
Problem about NSUserDefaults
After you register the defaults, you still need to do a sync to have
the values actually saved in the default database:
[[NSUserDefaults standardUserDefaults] synchronize];
See if that helps.
Sze Wong
Zerion Consulting
http://www.zerionconsulting.com
On Sep 27, 12:10 am, Tom <sunkunj…@gmail.com> wrote:
> i want to store some status of application to recover application’s
> status when start next time…for example, i want to display a
> content my last inputed in the searchBar when applicaltion start. i
> used NSUserDefaults like this:
> – (void)applicationDidFinishLaunching:(UIApplication *)application {
> [aViewController aSearchBar].text = [[NSUserDefaults
> standardUserDefaults] objectForKey:@”searchBarText”];
> …
> }
> – (void)applicationWillTerminate:(UIApplication *)application
> {
> NSLog(@”will terminate”);
> NSMutableDictionary *defaultValues = [NSMutableDictionary
> dictionary];
> NSString *searchBarText = [[NSString alloc] initWithString:
> [aViewController aSearchBar].text];
> [defaultValues setObject:searchBarText forKey: @"searchBarText"];
> [[NSUserDefaults standardUserDefaults] registerDefaults:
> defaultValues];
> NSLog([[NSUserDefaults standardUserDefaults]
> objectForKey:@”searchBarText”]);
> [[nbWikiUIController nbSearchBar].text writeToFile:@”searchBarText”
> atomically:YES];
> }
> but the content of searchBar is blank when you click the iphone
> simulator’s home button and start the appliclation again.how ever, if
> you write some value to a file directly it will work well, like this:
> – (void)applicationDidFinishLaunching:(UIApplication *)application {
> NSArray *paths =
> NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
> NSUserDomainMask, YES);
> NSString *documentsDirectory = [paths objectAtIndex:0];
> NSString *appFile = [documentsDirectory
> stringByAppendingPathComponent:@"searchBarText"];
> NSString *myString = [NSString stringWithContentsOfFile:appFile];
> [nbWikiUIController nbSearchBar].text = myString;
> …
> }
> – (void)applicationWillTerminate:(UIApplication *)application
> {
> NSLog(@”wikimate terminate”);
> [[nbWikiUIController nbSearchBar].text writeToFile:@”searchBarText”
> atomically:YES];
> }
> If you do like this, you will get this warning:
> warning: ‘writeToFile:atomically:’ is deprecated (declared at /var/
> folders/Mv/Mv45MRvrHuKkTR4seo+8kk+++TI/-Caches-/com.apple.Xcode.501/
> CompositeSDKs/iphonesimulator-iPhoneSimulator2.0-
> cwkscxilvbhpyzhgdmxradhnpbjc/System/Library/Frameworks/
> Foundation.framework/Headers/NSString.h:352)
> i don’t know why…
> many thanks.
Get a snapshot of the image in the current view
Are you trying to save an image of your active UIView into a file or
the photo library?
If so, here:
UIGraphicsBeginImageContext(pictureView.bounds.size);
[pictureView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
pictureView is the UIView that you want to save.
Sze Wong
Zerion Consulting
http://www.zerionconsulting.com
On Sep 30, 12:13 am, equrick <li…@nibirutech.com> wrote:
> screen? Are there some Api?
> many thanks.
Save files on the iPhone
Definitely. Read the following:
http://developer.apple.com/iphone/library/documentation/Cocoa/Concept…
The API supports FTP also.
I’ve not done FTP myself but we use NSURL to do HTTP Post/Get requests
and to send/receive standard content so what you are looking for is
definitely doable.
Sze Wong
Zerion Consulting
http://www.zerionconsultng.com
On Oct 3, 1:21 pm, Lata Rastogi <lethal.lo…@gmail.com> wrote:
> iPhone using Objective-C so that my app can use it the next time it
> runs.
> Basically, letting the user download some files from the internet on
> his phone to be viewed offline later.
> Is that possible?
> Regards
Save files on the iPhone Options
Are you trying to save files that sits on your desktop to the phone’s
file structure through xcode? If you are talking about ActiveSync kind
of file transfer, then the answer is no. The iPhone (if you didn’t
know yet) is a very close environment.
Now, that depends on why you want to do that. If you want to put a
file into the phone so your app can access it, then just put it along
with your app and you can reference it through NSBundle, like:
NSString *imagePath = [[NSBundle mainBundle]
pathForResource:fileName ofType:@”png”];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
I’ve also put pre-built SQLite files along with the bundle so that app
can access them.
Sze Wong
Zerion Consulting
www.zerionconsulting.com
On Oct 1, 12:21 pm, “Lata Rastogi” <lethal.lo…@gmail.com> wrote:
> Can I save remote files on the iPhone using xcode?
> Thanks!


