[Pythonmac-SIG] PyObjC: Errors initializing NSAttributedString using initWithHTML

Bob Ippolito bob at redivi.com
Tue Jan 10 23:29:37 CET 2006


On Jan 10, 2006, at 2:16 PM, Michael Glassford wrote:

> When trying to initialize an NSAttributedString like this:
>
> attributedString =
> AppKit.NSAttributedString.alloc 
> ().initWithHTML_baseURL_documentAttributes_(data,
> url, None)
>
> I get the error "TypeError: Need 2 arguments, got 3", although the
> documentation makes it pretty clear that there are in fact 3  
> arguments.
> Similarly,
>
> attributedString =
> AppKit.NSAttributedString.alloc().initWithHTML_documentAttributes_ 
> (data,
> url)
>
> gives the error "TypeError: Need 1 arguments, got 2", although the
> documentation makes it pretty clear that there are in fact 2  
> arguments.

The reason is because the last parameter is an output parameter.   
It's part of the result.

attributedString, attributes = AppKit.NSAttributedString.alloc 
().initWithHTML_baseURL_documentAttributes_(data, url)
attributedString, attributes = AppKit.NSAttributedString.alloc 
().initWithHTML_documentAttributes_(data)

This behavior is definitely documented.. I don't remember exactly  
where, don't have a checkout on me.

-bob



More information about the Pythonmac-SIG mailing list