Google Chrome Plugins

Google Chrome’s time has come. I love this browser because… it’s the fastest thing out there. It had a lot of glitches when it was first released. I remember Facebook wouldn’t work fine on it… and of course, i had to fix the HTML of many of the websites i maintain.

But i stil love it. It gets updated in background… and you hardly get to notice it!. As almost everything out there… it’s better when tweaked… right?. So i’d like to recommend three different plugins, available in the Chrome Web Store:

  1. AdBlock
    As weird as it may sound… popups are still annoying these days. Furthermore, websites with ads are the worst thing that could happen to you. At least while you’re surfing the web. Well, adBlock takes care of that. It just locks out popups, and disable the download of annoying banners. Try it!.
  2. Google Docs
    Wouldn’t it be great to access your google docs, without actually having to hit ‘docs.google.com’ ?. Well, Google Docs plugin allows you to access them right from a shortcut placed by the location bar.
  3. Firebug Lite
    Although it’s not a full version… it’s a lite… FireBug is one of the best plugins out there. It allows you to play, realtime, with the DOM. Just click few buttons, and you can tweak almost anything. Sorry to say this, but Firefox version of this plugin is sooo much better…

I hope this helps!

Xcode 4.3.1

If you haven’t done so… go grab the latest release of Xcode. But beware… as soon as you download it, it’ll overwrite your current 4.3 installation. It comes without sdk’s 5.0 and below. So… as usually… i recommend you do that after your looong working journey.

Otherwise you might find yourself stuck watching the download progress bar. No… that didn’t happen to me… i swear!.

Bad thing is that Apple didn’t fix the Refactor functionality, yet. It’s getting kinda difficult to rename class names. For some reason, i keep getting an annoying popup saying that it cannot be done. There are several posts in stackoverflow saying that Dropbox might cause that… but my projects are not inside a Dropbox folder, so that option can be discarded.

If i *ever* figure out how to make it work ok, i promess… i’ll post the solution, right here!

Preventing crashes: JSON Parsers & Null entries!

How many times you got to parse a backend response, and tested if a given value is != nil?. Well, as it turns out, many parsers (such as JSONKit) will parse ‘null’ values into an instance of NSNull. That might cause a crash… unless you write eeeverywhere… ‘!= nil && != [NSNull null]’.

So… a good idea would be to implement an NSDictionary extention, to do that. Right?.
The method would look like this:
[cc lang=”objc”]
– (id)objectForKeyNotNull:(id)key 
{
    id object = [self objectForKey:key];
    if (object == [NSNull null])
    {
        return nil;
    }
    else
    {
        return object;
    }
}[/cc]

Filtering arrays with NSPredicate!

Suppose you wanna filter a collection of objects. Normally, you’d write a while loop, implement a comparison, and add the matching objects to a collection.

Well, there is an easier way!!. For the sake of this example, say you wanna filter the objects that have the BOOL ‘isEnabled set to YES. So, you could do the following:

[cc lang=”objc”]
NSPredicate* predicate = [NSPredicate predicateWithFormat:@”isEnabled == YES”]; NSArray *filteredArray = [myArray filteredArrayUsingPredicate:predicate];
[/cc]

Yet another powerful example of NSPredicate would be… remember ‘SELECT* WHERE FIELD IN(1, 2)’ ?. Guess what!

[cc lang=”objc”]
NSPredicate* filterPredicate = [NSPredicate predicateWithFormat:@”field IN %@”, desiredFieldValues];
NSArray* filteredObjects = [allObjects filteredArrayUsingPredicate:filterPredicate];
[/cc]

Memory Management Tips!

It’s REALLY recommended that you set to nil any pointer that has a reference to a released object. But it’s tedious, right?. [pointer release]; pointer = nil;.

Why don’t we use a macro instead??
[cc lang=”objc”]
#define LAWipe(x)         [x release]; x = nil;
[/cc]

Simple. Nice. This should help you lower down the BAD_ACCESS crashes!.

 

%d