Projects

Ticket #95 (closed defect: invalid)

Opened 2 years ago

Last modified 2 years ago

uninitialized constant NSHomeDirectory

Reported by: jonathan@… Owned by: lsansonetti@…
Priority: minor Milestone:
Component: MacRuby Keywords:
Cc:

Description

Maybe I've done something wrong but.... I'm trying to access NSHomeDirectory and get 'uninitialized constant NSHomeDirectory'. This can be reproduced in MacIrb with: foo = NSHomeDirectory

S/w level: irb 0.9.5(05/04/13)

Change History

Changed 2 years ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to invalid

Do not forget to load the Cocoa framework first (loading only Foundation should work too), then since NSHomeDirectory is actually a C function, and that it starts with a capital letter, Ruby needs you to specify the parentheses otherwise it will think it's a constant.

$ macirb
>> NSHomeDirectory
NameError: uninitialized constant NSHomeDirectory
	from (irb):1
	from /usr/local/bin/macirb:12:in `<main>'
>> framework 'Cocoa'
=> true
>> NSHomeDirectory
NameError: uninitialized constant NSHomeDirectory
	from (irb):3
	from /usr/local/bin/macirb:12:in `<main>'
>> NSHomeDirectory()
=> "/Users/lrz"
>> 
Note: See TracTickets for help on using tickets.