From: Dave H. <gr...@gr...> - 2005-06-16 16:44:36
|
On Jun 14, 2005, at 12:01 AM, Jonathan Paisley wrote: > For this to work, you'd need to do > NSImage.alloc.initByReferencingFile(blahblah). > > However, I there's also NSImage.imageNamed(blahblah) which should work. Ah. Just when I thought I'd finally managed to really internalize and keep separate classes and instantiations, Obj-C rises up and bites me with the same thing. Hmm. OK, so the NSImage.alloc.initByReferencingFile(blahblah) didn't seem to work either, but NSImage.imageNamed(blahblah) worked perfectly. :) :) Except that it doesn't automatically update. If I roll the dice, and replace the data in the array, it only updates when I move focus to another app or back. I'm pretty sure I know how to fix that, but I thought to myself "oho! Wouldn't this be better if I used Bindings instead of simulating a datasource?" Well, maybe, but now I can't get *that* to work. All the examples I find are too complicated; they assume that I want to the user to be able to edit and fiddle. This is display only, so I need to be able to write into the array programmatically and have it update. I think what's not working is that I can't convince the table view to actually connect to the array. I'm mostly working off the Intro To Cocoa Bindings article on the cocoadevcentral site, which creates a little email mailbox & messages app. The final "code" for the project is this: @interface MyController : NSObject { NSMutableArray * _mailboxes; } - (NSMutableArray *) mailboxes; - (void) setMailboxes: (NSArray *)newMailboxes; @end I can't quite figure out how that translates into RubyCocoa. (The initial {} part is mystifying, dumb old Obj-C grumble grumble.) Here's my best guess so far: class MyController < OSX::NSObject include OSX ib_outlet :mailboxes def initialize @mailboxes = NSMutableArray.alloc.init end end There's no 'def setMailboxes' because I don't want mine to be writable, so I haven't been trying to figure out the correct syntax for that. Anything wrong so far? |