From: Laurent S. <lsa...@ap...> - 2007-07-04 09:47:41
|
Hi Tim. On Jul 4, 2007, at 10:52 AM, Tim Perrett wrote: > Hey Guys > > I am subclassing NSView to try and make a toolbar like the one in > iPhoto (the one which runs accross the bottom quarter of the window, > holiding the operation buttongs like "Play" and "Search"). I took a > look at what apple had done with iPhoto and it seems they subclassed > NSView, then subclassed there new subclass calling it IPToolbar. I > would look to replicate this, so i have subclassed NSView setting the > background colour with no problem. > > So my question is, if i had an array of items (NSMutableArray), how > would I add and remove items from my view? Would this just be like > adding and removing any other object? I have not done anything with > rolling your own views before, so im at a bit of a loss on the actual > implementation code.. I suggest you to have a look at: http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/index.html I suspect the "Working with the view Hierarchy" and "Creating a Custon View" sections will interest you :-) > Also, are there any performance issues in making the view code go > over the bridge? I see the RubyCocoaStickies example which seems to > work fine using RC for the view implementations. Normally no. I suggest you to start writing your implementation in Ruby, and if this turns out to be slow, you can profile the code and rewrite the slow code in ObjC. But before rewriting the code in ObjC, feel free to discuss this with us, maybe the code can be accelerated. Generally, you should just avoid to cross the bridge too often. For example, if you have a very complicated drawing method in your view (that calls the C/ObjC a lot), it can make your application a bit slow. But very recently in trunk, a powerful optimization was introduced. Calls from Ruby to ObjC should be a lot faster than in the previous releases. HTH, Laurent |