Hi,
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
Cheers,
John
mh
(marc hoffman)
January 4, 2022, 12:13pm
2
ToString should map to description
on Cocoa, unless explicitly implemented/overriden.
JohnMoshakis:
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
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 ?
mh
(marc hoffman)
January 4, 2022, 6:05pm
4
yeah, ToString won’t exist, it’s called description
, the compiler should handle this. I’ll try too. Island or Toffee V1 or ToffeeV2?
mh
(marc hoffman)
January 4, 2022, 6:07pm
5
FWIW, this is fine for me on Toffee/macOS:
writeLn('The magic happens here.');
var x := new StringBuilder;
x.Append("Hello");
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
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.
mh
(marc hoffman)
January 4, 2022, 6:31pm
7
:(. thats gonna make this tricky.
JohnMoshakis:
The stack
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
ToffeeWatchLibrary.zip (110.6 KB)
That is my static library. Im just building the Toffee watch os version
This is swift xcode project
mh
(marc hoffman)
January 4, 2022, 8:54pm
11
thanx.
if you replace exit with
writeLn(builder);
//writeLn(builder.ToString);
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 ');
builder.Append('StringBuilder');
exit builder.ToString;
result := builder as String
worked
ck
(Carlo Kok)
January 5, 2022, 9:28am
13
So this is a little trickier than it sounds. ToString is an extension method:
extension method Foundation.NSObject.ToString: PlatformString;public;
begin
result := description;
end;
@mh I think this will need debugging on a watch.
mh
(marc hoffman)
January 5, 2022, 12:28pm
15
John: are you linking in libToffee for this one?
mh
(marc hoffman)
January 5, 2022, 2:26pm
17
damn. SOund slike maybe a linker issue eliminating the symbol :(.
mh
(marc hoffman)
January 5, 2022, 2:30pm
18
Can you send me your wacthOS exe binary?
mh
(marc hoffman)
January 6, 2022, 9:27pm
20
Do you have -ObjC
in the linker flags in Xcode? if not, can you add it?
I dont and it fixes it What does that do ?