On Dec 28, 2005, at 9:09 PM, Manfred Bergmann wrote:
The toll-free bridge also includes something like this?
my $str = NSString->stringWithString("astring");
where with PerlObjCBridge you have to use this:
my $str = NSString->stringWithCString_("astring");
Yes - strings are bridged both ways. Although, tied objects aren't
passed or returned, just copies. Because Perl's "native" string-
handling is generally more useful from within Perl scripts than
NSString's methods, the default for methods that return NSString
objects is to return them as string scalars. So the $str in the above
wouldn't be a blessed NSString object reference, just an ordinary
scalar.
You can get NSString objects if you want, by setting
$CamelBones::ReturnStringsAsObjects to a non-zero value. You can use
local() to localize the change, like this:
my $str;
{
local $CamelBones::ReturnStringsAsObjects = 1;
$str = NSString->stringWithString("aString");
# $str is an NSString object
}
# After the local() above falls out of scope, ReturnStringsAsObjects
reverts back to its
# old value. So, this method returns a scalar string, not an object.
print $str->uppercaseString();
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org