Type mismatch, cannot assign "array of NSString" to "array of RemObjects.Elements.RTL.String"

Hi,

I have 2 mac console apps, one is Toffee the other is island. x

ConsoleApplication2.zip (7.7 KB)
ConsoleApplication12.zip (655.3 KB)

Should the Island one fail to build with ?

Type mismatch, cannot assign “array of NSString” to “array of RemObjects.Elements.RTL.String” [/Users/JohnMoshakis/Documents/develop/Island/ConsoleApplication2/Program.pas (15)]
← Phase Resolving Bodies finished, took 0.532s.

Cheers,
John

On Island (unless using ToffeeV2), RemObjects.Elements.RTL.String maps to Island’s native cross-platform string type, System.String.

While individual System.String and NSStrings can be seamlessly cast to one another (at a cost), they are distinct types, and so an array (or a List) of them, will not be compatible, as each individual String would have to be cast/converted, and that’d not happen in the case of casting a container.

You’ll need sometng explicit such as myNSStringArray.Cast<System.String() or myNSStringArray.Cast(s -> s as System.String).

Would something like this be correct ?

uses
  RemObjects.Elements.System,
  RemObjects.Elements.RTL;

type
  EnvironmentExtensions = public extension class(RemObjects.Elements.RTL.Environment)
  private
  protected
  public
    class method CommandLineArgs:array of String;
    begin
      
      {$IFDEF ECHOES}
      exit System.Environment.GetCommandLineArgs;
      {$ELSEIF TOFFEE}
      exit Foundation.NSProcessInfo.processInfo.arguments.ToArray;
      {$ELSEIF DARWIN}
      exit Foundation.NSProcessInfo.processInfo.arguments.ToArray.Cast<System.String>.ToArray;
      {$ELSE}
      raise new NotImplementedException;
      {$ENDIF}

    end;
  end;


Im not sure about the 2 ToArrays

Cheers,
John

Should be, yes. the ToArray before Cast is porlly redundant/unnecessary.