0

Writing a Lazarus unit with Objective Pascal to interface with Cocoa classes on Mac OS X. I want to pass an AnsiString from the FreePascal caller to a Cocoa class requiring an NSMutableData parameter value. How can I cast or convert the AnsiString data to NSMutableData data, coding in the Objective Pascal dialect?

Thanks for your consideration!

Lor
  • 141
  • 10

1 Answers1

0

Well duh...

MyMutableData := MyMutableData.appendBytes(@MyAnsiString[1], SizeOfString);

The appendBytes method of NSMutableData takes a pointer, so @MyAnsiString[1] provides it.

The [1] bypasses the length and counter info prepended to the actual ansistring.

Lor
  • 141
  • 10