Re: [Pyobjc-dev] NSAttributedString returns a tuple, not an NSAttributedString
Brought to you by:
ronaldoussoren
From: Diez B. R. <de...@we...> - 2010-10-17 10:00:49
|
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 |