Thursday, March 14, 2013

Twitter tip - How to undo a retweet (web)

Earlier in the morning I wanted to undo a retweet I did. It took me a while to figure out how to. Just posting it here for future use and for you who is reading this right now.

1. Find the tweet your retweeted.
2. Notice that the retweet link now says retweeted.
3. Click on it

Tuesday, February 19, 2013

NSView AutoresizingMask explained

You can make your NSViews auto arrange/resize according to its superview's size by setting appropriate values using NSView's setAutoresizingMask: method. For this example's sake I'll consider elements added as subviews to the contentView of the NSWindow. NSWindow can change its size when going into full screen, when the user clicks on the resize control (green button) and when the user manually resize the window. For a better UI experience it is required to re-arrange/re-size the elements according to the change in size of the NSWindow.

Sunday, October 14, 2012

Check for both null and nil to avoid crash - objective c

Sample code

line 1: NSString *someString;
line 2: someString = [self getStringValue];
line 3: NSLog(@"length of the string = %d",[someString length]);

In the above example sometimes the code can crash at line 3. Possible reason would be that the object "someString" is either null or nil. null vs nil has always been a debate with my friends, when to use and what to check and so on. If you don't have access to the contents of "getStringValue" method you'd probably have to check for both.

if (![someString isEqual:[NSNull null]] && (someString != nil)){
NSLog(@"length of the string = %d",[someString length]);
}

Wednesday, October 3, 2012

Objective C - missing documents directory

Did you know that by using "removeItemAt:" method in NSFileManager you could actually delete the documents directory? It is bit of a scary thought and I sometimes feel that it shouldn't be the case to keep careless developers away from bugs, but unfortunately or not it is possible.

Thursday, August 9, 2012

Mac OSX Mountain Lion unidentified developer

Looks like Apple is serious about provisioning and developer certificates for Mac apps from their latest Mac OSX version (10.8 - Mountain Lion). It has always being the case for iOS apps but not for Mac apps. Just got this error while trying to install Fink

Tuesday, May 22, 2012

Can’t add UIImagePickerViewController’s view as a sub view – iOS 4

Incorrect code sample

UIImagePickerController *pickerController = [[UIImagePickerController alloc]init];
pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
pickerController.delegate = self;
[self.navigationController.view addSubview:pickerController];
[pickerController release];

Actually there is nothing wrong with the addSubview method. The only problem is that it doesn’t load the gallery.

Friday, May 11, 2012

UINavigationBar default back button - iOS 5

It is common knowledge that the UINavigationBar will display the previous UIViewController's title in an arrow shaped button at the left hand side corner. Basically if the previous UIViewController doesn't have a title the back button won't be visible as well.

Sunday, April 1, 2012

Add files to an existing zip - objective c, ZipArchive

I'm using ZipArchive developed by aish to create zip files. ZipArchive is an Objective-C class to compress or uncompress zip files, which is based on open source code "MiniZip". It worked fine on many of the iPhone apps I developed.

Thursday, March 22, 2012

UINavigationBar tintColor, why not backgroundColor or color?

I don't know whether its just me but, whenever I'm thinking of changing the colour of an UI element first thing I would do is look for methods like setBackgroundColor or setColor before I think of subclassing the element and overriding its drawRect (for more customised application of colours you will have to override "drawRect"). Unfortunately in objective c UINavigationBar colour is reffered as tintColor. So I thought of documenting it for future reference.

Monday, March 5, 2012

Branch condition evaluates to a garbage value (Xcode Analyze tool result)

Two things you need to understand first

1. Branch condition : probably a if statement
2. Garbage value: Every variable has a garbage value prior to any initialisation

"Branch condition evaluate to a garbage value" would probably mean that there could be an instance where your code (if statement in this case) tries to evaluate a variable/object which is not initialised.

The analyze tool in Xcode gave me this as one of its analyzer results. The problem code was as follows.

Tuesday, February 7, 2012

Two things I like about facebook timeline

I should say that I also some what agree with the buzz about how annoying the new timeline feature is. As it is said that facebook timeline is not going to be an optional feature anymore. Facebook will gradually turn all its user's profiles in to the timeline mode. However you will get 7 days trail period to recheck your privacy settings. With the new timeline. You will really have to re-think about your privacy settings. Most of the complains about the change in privacy settings.