07 September 2011 by Published in: Code No comments yet

I “ported” thorncp’s fsck to objective-C this week.  fsck lets you tell the compiler how you really feel.

Disclaimer: Although fully functional, this is a joke / prank project.  Do not actually use it in production.

Examples

Convenience constructors got you down? Just

//give me a freaking array
    NSMutableArray *myArray = [NSMutableArray giveMeAFreakingArray];

Tired of boxing primitive types? Show the compiler who’s boss!

for(int i = 0; i < 10; i++)
    {
        NSNumber *myNumber = [NSNumber hateBoxingNumberWithInt:i];
        [myArray addTheFreakingObjectOrElse:myNumber];
    }

Keep forgetting how to write a block definition?

[myArray enumerateThesePointlesslyBoxedObjectsUsingUnreadableBlockSyntax:^(id obj, NSUInteger idx, BOOL *stop) {
        NSLog(@"%@",obj);
    }];

Do you think descriptions are AWESOME!?!

NSLog(@"%@",[@"Hello, world!" thisDescriptionIsAwesome]);

Usage

All you have to do is add NSObject+fsck.m to the project. I am completely serious. You don’t have to touch a single file. Just be sure to check it into source control over lunch, when they won’t notice…

How does this work?

Short version, fsck deletes random words from your method invocations until it finds a method matching the signature.

Long version, fsck hooks into forwardInvocation:, which is similar in spirit (but much more complicated) than Ruby’s missing_method.

Sound good?  Get it from GitHub.


Want me to build your app / consult for your company / speak at your event? Good news! I'm an iOS developer for hire.

Like this post? Contribute to the coffee fund so I can write more like it.

Comments

Comments are closed.

Powered by WordPress