Re: [Pyobjc-dev] issues with NSURL and NSWindow?
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2004-04-05 03:55:41
|
On Apr 4, 2004, at 11:37 PM, b.bum wrote: > On Apr 4, 2004, at 8:18 PM, James Eagan wrote: >> I've been doing more with PyObjC lately, and I've been having a few >> weird issues creep up.... The first one's probably the easiest to >> demonstrate: >> >> Python 2.3 (#1, Sep 13 2003, 00:49:11) >> [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >> >>> from Foundation import * >> >>> u = NSURL.alloc().initWithString('http://pyobjc.sf.net') >> Bus error >> % > > That should be: > > >>> from Foundation import * > >>> u = NSURL.alloc().initWithString_('http://pyobjc.sf.net') > > But the incorrect form shouldn't bus error, either... It's releasing something that was alloc'ed but not init'ed. It probably should bus error. I'm not sure how we are supposed to catch that anyway? I guess we would have to keep track to see if it was alloc'ed but not initialized, and then send it dealloc instead of release. This gets a bus error too, btw: #import <Foundation/Foundation.h> int main (int argc, char **argv) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSURL *url; url = [NSURL alloc]; [url release]; [pool release]; } In any case, you are far better off using NSURL.URLWithString_(u'http://pyobjc.sf.net/') .. in general I would recommend avoiding alloc/init from PyObjC in exchange for the autoreleased classmethod version, if for no other reason than aesthetics. Surely the amount of code you have to type is proportional to the number of mistakes you can make :) -bob |