Anyway, the line #23 raises an error on execution:
par.setTextLists(NSArray(textLists));
How could I convert the NSTextLists textLists to an NSArray?
NSTextLists and NSArray are completely unrelated classes, so it's normal that typecasting doesn't work:
https://developer.apple.com/documentation/appkit/nstextlist?language=objc . Objective-C and Object Pascal are the same as far as that it concerned.
I don't know whether there is a convenience method to get an NSArray containing all elements from an NSTextList, and if not, what the best way would be to manually create one. I only work on the compiler support for Objective-Pascal, I don't do any Cocoa programming.
Edit: looking at the declaration of setTextLists, I see you actually want to create an NSArray containing a single element, with this single element being "textLists" (rather than an array representation of the contents of textLists). While Pascal and Objective-Pascal have some differences, things like typecasts are exactly the same in both. So NSArray(textLists) tries to typecast textLists into NSArray, rather than construct an NSArray with that variable as its single element.
In that case, you would use
https://developer.apple.com/documentation/foundation/nsarray/1411981-arraywithobject?language=objc , so something like NSarray.arrayWithObject(textLists)
Edit 2: removed the '.alloc' in NSarray.arrayWithObject(textLists), as that's a convenience method that already does the alloc implicitly.