[Pyobjc-dev] Bridging strings
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2002-11-02 04:17:17
|
Because the bridge converts strings as they go back and forth, there is no way to invoke certain methods on NSString. I.e. I can't (totally bogus example, yes, but there are uses for this stuff in other contexts -- -drawString:... immediately comes to mind): [bumbox:~/bbum-developer/sourceforge/pyobjc] bbum% python Python 2.2 (#1, 07/14/02, 23:25:09) [GCC Apple cpp-precomp 6.14] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from Foundation import * >>> x = NSString.stringWithString_( "foo bar baz" ) >>> type(x) <type 'str'> >>> x.componentsSeparatedByString_( " " ) Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'str' object has no attribute 'componentsSeparatedByString_' >>> NSString.componentsSeparatedByString_( x, " " ) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: First argument must be an objective-C object, got 'foo bar baz' If we moved to bridging strings in the same fashion as we bridge the various arrays and dictionaries, it should be possible to bridge both ways in a transparent fashion? Hmmm.... b.bum (thinking out loud) |