In RTL2 for toffee stringbuilder is mapped to Foundation.NSMutableString. On a stringbuilder I can do ToString. Where does ToString come from ? It’s not part of the StringBuilder class, on NSString or NSObject.

It looks like on watchos it doesnt exist, I get

‘NSInvalidArgumentException’, reason: ‘-[__NSCFString ToString]: unrecognized selector sent to instance 0x600002afcf60’

terminating with uncaught exception of type NSException

CoreSimulator 783.5 - Device: Apple Watch Series 7 - 45mm


ToString should map to description on Cocoa, unless explicitly implemented/overriden.

Hmm. same is fine on macOS or iOS, or you didn’t test?

Thanks. Yes I tested on macos

That error is saying that the method doesnt exist ?

yeah, ToString won’t exist, it’s called description, the compiler should handle this. I’ll try too. Island or Toffee V1 or ToffeeV2?

FWIW, this is fine for me on Toffee/macOS:

      writeLn('The magic happens here.');
      var x := new StringBuilder;
      writeLn($"x {x}");
      writeLn($"x.ToString {x.ToString}");

but it might also matter how you call ToString/how ToString gets called implicitly.

Update also fine on ToffeeV2 and pure Island (macOS; im not in a position to test watchOS without losing a day and my sanity :wink:

Its Toffee v1. It also works for me with macos.

The stack seems to indicate its coming from JsonTokenizer in the parse method. I’ll have a go later will just a simple example and see if that works.

:(. thats gonna make this tricky.

Can you share this stack, and the line of user code that it starts with?

I’ll create an example that just uses stringbuilder and see if that has the same issue

1 Like

Screen Shot 2022-01-04 at 3.04.18 PM (110.6 KB)
That is my static library. Im just building the Toffee watch os version

This is swift xcode project

Logged as bugs://E25606.


if you replace exit with

result := builder as Stting

does it work? (even if you cant see the writeLn probably):?

      var builder := new StringBuilder;
      builder.Append('hello ');
      builder.Append('from ');
      exit builder.ToString;

result := builder as String


So this is a little trickier than it sounds. ToString is an extension method:

extension method Foundation.NSObject.ToString: PlatformString;public;
  result := description;

@mh I think this will need debugging on a watch.

John: are you linking in libToffee for this one?

Yes I am

damn. SOund slike maybe a linker issue eliminating the symbol :(.

Can you send me your wacthOS exe binary?

MyWatchApp WatchKit (627.6 KB)

Do you have -ObjC in the linker flags in Xcode? if not, can you add it?

I dont and it fixes it :slight_smile: What does that do ?