Forums RubyCocoa

 
Me_at_euruko08_square_-_head_only_small Dr Nic 2 posts

In the pdf, around p47-48 it discusses the use of #new vs #init.alloc based on the latter being a descendent of NSObject. I started a RubyCocoa.tmbundle to attempt to help pick the correct one (http://github.com/drnic/rubycocoa-tmbundle/tree/master).

If you’ve got:

class Sender < OSX::NSObject
end

Sender.<press tab>
</code>

when you press tab it autocompletes to Sender.init.alloc Non-NSObject subclasses autocomplete to .new

Hopefully this is helpful for newbies like me.

 
Cuttlefishhead_100x100_small christophe 3 posts

thanks for that doc!

 
Cuttlefishhead_100x100_small christophe 3 posts

i have come up with a way
to just write new instead
of alloc.init

http://pastie.org/324314

it also calls initialize
so that you can code as
you normally would.

in cases where you just
want to subclass NSObject
and then build a little
class hierarchy under your
subclass this comes in real
handy. in more complicated
cases i’m not too sure yet.

still too green behind the ears.
any comments?

3 posts, 2 voices