Re: NSAttributedString returns a tuple, not an NSAttributedString
"Diez B. Roggisch" <[email protected]>
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <[email protected]> |
On Oct 17, 2010, at 10:56 AM, Michael Thon wrote: > Hello - I am trying PyObjC for the first time and I discovered something that I don't understand. If I initialize an NSAttributedString like this: > > content = NSAttributedString.alloc().initWithPath_documentAttributes_(a_path, None) > > Then content contains a tuple, not an NSAttributedString. If I initialize is like this: > > content = NSAttributedString.alloc() > a_tuple = content.initWithPath_documentAttributes_(a_path, None) > > Then content contains an attributed string from the contents of the file, and a_tuple contains a tuple. On the other hand NSAttributedString.alloc().init() > returns an instance of NSAttributedString, as expected. So, apparently initWithPath_documentAttributes_() returns a tuple instead of an instance of NSAttributedString. My question is, is this by design (and thus, there is something about PyObjC that I don't understand) or is it a bug? It's by design. Pay close attention to the argument list: the parameter you pass as None is a pointer to a pointer. Which means it is an out-parameter. Python lacks the semantics for this, so instead, signatures of that kind are implemented by returning the value as tuple. Diez ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev