|
From: Steven A. <st...@ne...> - 2005-08-23 01:12:16
|
Hi Jonathan, thanks for your reply.
On Aug 22, 2005, at 4:19 PM, Jonathan Paisley wrote:
> On 22 Aug 2005, at 17:45, Steven Arnold wrote:
>
>> When I call self.getFormValues, I do not get back a Ruby Hash, but
>> rather a Cocoa NSCFDictionary. Right before the return, it's a
>> hash....but when it gets back, it's an NSCFDictionary.
>
> Could you include the exact code you're using when calling
> getFormValues? The behaviour ought to be as you're hoping, but it
> won't if the method call is going via the Objective C bridge.
Here's a complete program, runnable on the command-line, that will
break. If you comment out the "private" line and the attr_accessor
line, it will work. It does not have the same problem with public or
protected attributes!
Weird...... Any thoughts?
require 'osx/cocoa'
class X < OSX::NSObject
private
attr_accessor :datamanager
def getHash
{}
end
def me
self
end
def selfGetHash
self.getHash
end
end
x = X.alloc.init
p x.getHash #=> {}
p x.me #=> #<X:0x812db2 class='X' id=0x12a02f0>
p x.selfGetHash #=> {}
p x.oc_me #=> #<X:0x812db2 class='X' id=0x12a02f0>
p x.oc_getHash #=> #<OSX::OCObject:0x80e596 class='NSCFDictionary'
id=0x12a9f30>
p x.oc_selfGetHash #=> #<OSX::OCObject:0x80d844
class='NSCFDictionary' id=0x12abc30>
steve
|