That's a good tip, I haven't gotten the hang of Cocoa's verbosity yet. The choice of read: was to balance write:. The whole thing started because I found it odd that writing an image to a file was such a convoluted process. In a lot of ways, Cocoa makes things really easy, but when it isn't easy, sometimes it becomes really, really hard (at least hard to figure out, if not to implement).

Some of that is just getting to know the libraries, of course, and a lack of howtos for the things I'm trying to do.

--Dethe

On 27-Jan-05, at 12:57 PM, Bob Ippolito wrote:


On Jan 27, 2005, at 15:24, Dethe Elza wrote:

FYI, once I updated PyObjC from svn, my example code worked, thanks again Ronald.
...
class NSImage(Category(NSImage)):

    def rect(self):
        return (0,0),self.size()

@classmethod # for Python2.3 replace with read_ = classmethod(read_)
def read_(cls, filepath):
return NSImage.alloc().initWithContentsOfFile_(filepath)

Just a nit here, you should probably call this imageWithFilePath_ to follow convention. "read:" is a really confusing name for an initializer.

-bob



"...coding isn't the poor handmaiden of design or analysis. Coding is where your fuzzy, comfortable ideas awaken in the harsh dawn of reality. It is where you learn what your computer can do. If you stop coding, you stop learning." Kent Beck, Smalltalk Best Practice Patterns


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to