That Facebook strip

No, not a comic strip nor anything else that uses the “strip” word. But rather this component which lately has appeared in many different iPhone applications (see below some screenshots from the Facebook, the LinkedIn and the TSRinfo ones), and which I simply reimplemented, and then posted the code to Github for everyone to enjoy and use.

Update, 2009-02-24: I have just been told via Twitter by enormego that two weeks ago they have released another “Facebook strip” in Github! You might want to check it out. Mine is much simpler as far as I’ve seen, in particular I don’t have a custom class for buttons… :)

Going Github

This is something I’ve been looking forward to do for some time. After praising git back in 2007, now I’m moving many of my personal projects to Github, which has an absolutely brilliant service! For the moment I’m using the free account, but I will most probably switch to a paid account soon. The only thing it lacks, in my opinion, is a bug & issue tracker as you have in Google Code repositories, but other than that, it’s simply perfect.

So feel free to check out the projects I’ve moved there, and of course, to fork them and enjoy the code as you see fit.

Objective-C REST Client Update

I’ve uploaded (yet another) update to the Objective-C REST client I’ve blogged about previously. This time I’ve scanned the code with the excellent LLVM/Clang Static Analyzer and fixed a couple of memory leaks here and there. I strongly recommend to scan your own projects with this tool, it’s extremely simple to use:

  1. Install it somewhere in your PATH;
  2. Set your projects to use the Debug configuration when building from the command line (you can do that in the inspector for the project, in the “Configurations” tab); (see Sebastien’s comment below ;)
  3. Open Terminal.app and fire
    scan-build -k -V xcodebuild
    on the root of the Xcode project folder;
  4. If there are any problems with your code, you’ll have your web browser pop up with the list of problems, their description in annotated code format, and even a link to open the file right away.

Continue reading

Best books of 2008

You might remember my beloved mantras: learning a new programming language and reading at least 6 relevant books every year. Following the 2007 edition, here’s the list of the 8 books I have enjoyed most in 2008, ordered by a purely subjective and absolutely irrational decreasing preference. I strongly recommend all of them!

Winner: Geekonomics: The Real Cost of Insecure Software by David Rice

Runner-up: The No Asshole Rule: Building a Civilized Workplace and Surviving One That Isn’t by Robert I. Sutton, PhD

And 6 more:

Continue reading

iPhone Font Browser

One of the most common questions I get when working with clients on iPhone apps is this one:

Which fonts can I use in iPhone apps?

I was surprised to see that the Xcode documentation does not bring a list of the fonts available in the iPhone OS (have I missed it? Is it somewhere else?), and I was happy to find this blog post the other day. Taking his idea as a basis, I’ve created a font browser for the iPhone which I’ve published in the projects section of this blog.

Feel free to play with the code! As usual, no warranties of any kind, but I’m already using it every day :)

REST and Objective-C, again

I’ve just uploaded some code derived from the Objective-C wrapper I’ve shown in this post. You can find it in the “Projects” section, as usual and it’s simply a wrapper around the URL loading system of Cocoa, both for Macs and iPhones, providing a custom delegate protocol, so that you can handle the events raised by the wrapper:

[source:C::firstline(13)] @protocol WrapperDelegate

@required - (void)wrapper:(Wrapper *)wrapper didRetrieveData:(NSData *)data;

@optional - (void)wrapperHasBadCredentials:(Wrapper *)wrapper; - (void)wrapper:(Wrapper *)wrapper didCreateResourceAtURL:(NSString *)url; - (void)wrapper:(Wrapper *)wrapper didFailWithError:(NSError *)error; - (void)wrapper:(Wrapper *)wrapper didReceiveStatusCode:(int)statusCode;

@end [/source]

The sample project, available in the zip file, shows how a simple Cocoa controller can interact with the Wrapper class as required. Enjoy!

Update, 2008-10-26: After a bug report from StuFF mc I’ve updated the code for a better support of POST and PUT requests, and also added a sample PHP file for a quick test of the functionalities.

iPhone Conference 2008 Geneva

Those of you who have been following this blog for the past years know that I have somewhat reduced my “writing rhythm” these days, and many factors have caused this. For the past 3 months I’ve been not only finishing my Master’s degree, but I started working as a full-time, independent iPhone developer, and soon some of my code will be available on the AppStore.

But in the meantime, I’m also starting a new business, and I’ve seen that many companies want to get into the iPhone application business in one way or another, and they have many questions.

To answer most of them all at once, and without breaking any NDA, we want to introduce you to The iPhone Conference 2008. This event is targeted to decision makers: whether you’re a CIO, CEO, marketing manager, responsible of corporate communications, we’ve got a message for you:

This event will be the first in Switzerland targeting the iPhone (that we’re aware of, of course). It will be held in Geneva, at the CICG, and it will be held in English. I think that there are huge business opportunities opening right now with the iPhone; I hope to meet you there!

Dangers of Prototyping

Frederick P. Brooks Jr. has written about prototypes, saying that they are not only useful but strictly fundamental pieces of the overall software process, as in many other engineering activities. He gives the example of a pilot chemical plant, prepared to process 10’000 units per day instead of the 2 million units a day that the final plant would have to handle, in order to demonstrate the feasibility and uncover some unforeseen problems.

He summarizes his opinion in the famous phrase “plan to throw one away” (Brooks, 1995, page 116), underlining the problem of change management: managing change, right from the beginning of the project, instead of ignoring or avoiding it, is particularly important in software projects, since it presents a solid mindset for all stakeholders in order to avoid scope creep, schedule and staffing problems. Continue reading

The beauty of Cocoa

(Highly geeky post ahead. You’ve been warned!)

I have found the very message that summarizes the beauty of Cocoa in a single word; see by yourselves, hereunder in line 47:

[source:c]

import

// The interface of a person @interface Person : NSObject { NSString* firstName; NSString* lastName; int age; } @end

// The implementation of the Person @implementation Person -(id)init { if (self = [super init]) { firstName = @”"; lastName = @”"; age = 0; } return self; }

-(void)dealloc { [firstName release]; [lastName release]; [super dealloc]; }

-(NSString*)description { return [[NSString alloc] initWithFormat:@”Name: %@ %@, %d years old”, firstName, lastName, age]; } @end

// Some code using the Person class int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSMutableDictionary* dict = [[[NSMutableDictionary alloc] init] autorelease];
[dict setObject:@"Teto" forKey:@"firstName"];
[dict setObject:@"Rodriguez" forKey:@"lastName"];
[dict setObject:[[NSNumber alloc] initWithInt:34] forKey:@"age"];
Person* person = [[[Person alloc] init] autorelease];
// The beauty of Cocoa can be resumed to this very line:
[person setValuesForKeysWithDictionary:dict];
// Now sit back and relax:
NSLog([person description]);
[pool drain];
return 0;

} [/source]