[Pythonmac-SIG] More on init
Bob Ippolito
bob at redivi.com
Wed Jul 6 13:37:44 CEST 2005
On Jul 4, 2005, at 6:04 AM, Aldo Bergamini wrote:
> An update on my fiddling:
>
>
> <snippet>
>
> from Foundation import *
> from AppKit import *
>
>
> from PyObjCTools import NibClassBuilder
>
> class PySayTextAppDelegate(NibClassBuilder.AutoBaseClass):
> # IB defined outlets
> # textField
> # speechSynthetizer
> #
> # IB defined actions
> # sayIt_
> # stopIt_
>
> def init(self):
>
> NSLog("init")
>
> self.speechSynth = NSSpeechSynthetizer.alloc()
> self.speechSynth.initWithVoice_(None)
>
> return self
>
> </snippet>
>
>
> In this version the init method gets called. I did remove the
> attempt to
> call the super class' init method.
NEVER remove the attempt to call the super's init method. ALWAYS
call the designated initializer.
> I know that the method IS called as I get an exception on
> NSSpeechSynthetizer.alloc() (hooray... ;-) : NSSpeechSynthetizer is
> not
> defined, apparently.
It's not defined because you didn't spell the class correctly.
> An attempt to import <Cococa> failed miserably...
Cocoa imports Foundation, AppKit and potentially CoreData. You need
to import those separately from PyObjC.
-bob
More information about the Pythonmac-SIG
mailing list