top | item 3868187

(no title)

buff-a | 14 years ago

Because its actually:

file.rb:

  require 'stuff'

  class foo
    def something
      alert = UIAlertView._alloc \
        ._initWithTitle _S("Hello"),
        :message, _S("I'm MobiRuby"),
        :delegate, nil,
        :cancelButtonTitle, _S("I know!"),
        :otherButtonTitles, nil
      alert._show
    end
  end
Instead of

file.h

  #import <stuff>
  @interface foo
    -(void)something:(BOOL)what andthen:(CGRect)thisthing
  @end
and then file.m

  #import <otherstuff>
  #import <yetmorestuff>
  #import "file.h"
  #import <oh shit is this in the right place?.h>
  #import <i think this is ok>
  #define SOME_HACK
  #import <this better come after that define up there.h>

  @implementation foo

  -(void)something:(BOOL)what butthen:(CGRect)thisthing
  {
   alert = [[UIAlertView alloc] 
                initWithTitle:@"Hello"
                message:@"I'm ObjC"
                delegate:nil
                cancelButtonTitle:@"I know!"
                otherButtonTitles:nil];
     [alert show];
  }
Fuck that.

1. Don't Repeat Yourself. Computer have more memory than 1986.

2. Don't forget to turn on warnings-as-errors, otherwise that code above will compile and then break because (of course you noticed) the method declaration doesn't actually match the declaration but the compiler doesn't care because its a brutal hack.

discuss

order

No comments yet.