H
Harry
Hello,
(to Kevin Bullock in this group: when searching for a solution, I saw
your answer to my earlier question in c.l.r. about this, not here in
c.l.r., but on some ruby-talk site, where you asked for the source
code of the dummy app: I included it here. I also followed the
instructions suggested on the ruby-cocoa mailing list at sourceforge,
alas, no show yet ...)
My first question is: has anyone had any succes in building and
running a RubyCocoa / Cocoa Bindings (aka Cocoa Controller Layer)
project? I tried to do a dummy-app along the execellent tutorial at
(using ruby1.8 instead of ObjC):
http://www.macdevcenter.com/pub/a/mac/2004/04/06/cocoa.html?page=1
Building the interface according this tutorial and test-driving it in
Interface Builder works fine.
In a first attempt, my Book.rb looked like this:
class Book < OSX::NSObject
attr_accessor :title
attr_accessor :author
end
Running the app gave me this error:
/Users/hvs/tmp/bibliotecha/build/bibliotecha.app/Contents/Resources/
rb_main.rb:19:in
`NSApplicationMain': NSApplicationMain - NSUnknownKeyException -
[<Book 0x4f2540> valueForUndefinedKey:]: this class is not key value
coding-compliant for the key title. (OSX::OCException)
from
/Users/hvs/tmp/bibliotecha/build/bibliotecha.app/Contents/Resources/
rb_main.rb:19
After reading some more docs on Apple's ADC site, about key value
coding (KVC) -compliancy, I change my code to:
class Book < OSX::NSObject
attr :title
attr :author
def title
return @title
end
def author
return @author
end
def setTitle(title)
@title = title
end
def setAuthor(author)
@author = author
end
end
It's ugly, but a KVC-compliant object needs set<Key> methods. But this
gave me the same error.
How to make Book KVC-compliant???
thx,
Harry
(to Kevin Bullock in this group: when searching for a solution, I saw
your answer to my earlier question in c.l.r. about this, not here in
c.l.r., but on some ruby-talk site, where you asked for the source
code of the dummy app: I included it here. I also followed the
instructions suggested on the ruby-cocoa mailing list at sourceforge,
alas, no show yet ...)
My first question is: has anyone had any succes in building and
running a RubyCocoa / Cocoa Bindings (aka Cocoa Controller Layer)
project? I tried to do a dummy-app along the execellent tutorial at
(using ruby1.8 instead of ObjC):
http://www.macdevcenter.com/pub/a/mac/2004/04/06/cocoa.html?page=1
Building the interface according this tutorial and test-driving it in
Interface Builder works fine.
In a first attempt, my Book.rb looked like this:
class Book < OSX::NSObject
attr_accessor :title
attr_accessor :author
end
Running the app gave me this error:
/Users/hvs/tmp/bibliotecha/build/bibliotecha.app/Contents/Resources/
rb_main.rb:19:in
`NSApplicationMain': NSApplicationMain - NSUnknownKeyException -
[<Book 0x4f2540> valueForUndefinedKey:]: this class is not key value
coding-compliant for the key title. (OSX::OCException)
from
/Users/hvs/tmp/bibliotecha/build/bibliotecha.app/Contents/Resources/
rb_main.rb:19
After reading some more docs on Apple's ADC site, about key value
coding (KVC) -compliancy, I change my code to:
class Book < OSX::NSObject
attr :title
attr :author
def title
return @title
end
def author
return @author
end
def setTitle(title)
@title = title
end
def setAuthor(author)
@author = author
end
end
It's ugly, but a KVC-compliant object needs set<Key> methods. But this
gave me the same error.
How to make Book KVC-compliant???
thx,
Harry