The reason your code didn’t work is that Uno arrays are not automatically converted to NSArray* in foreign Objective-C since this is not always what you want. You can instead use macros as above to create Uno arrays, fill them, and return them from foreign code. I’ll make an internal issue on improving the documentation on this.
Hate to hijack this thread, but the troubles I’m having seemed relevant.
I’ve got something like the following. someNativeLibrary has a method that takes a block (provided with an NSArray* argument). On the Uno side, I have an Action that needs to be called with those arguments:
[Foreign(Language.ObjC)]
extern(iOS)
public void Example(Action<string, object[]> messageHandler)
@{
return [someNativeLibrary withCallback:^(NSString* action, NSArray* args) {
// create Uno array
int count = 0;
@{object[]} unoArgs = nil;
if (args != nil) {
count = args.count;
unoArgs = @{object[]:New(count)};
// iterate and copy over
int i = 0;
for (i = 0; i < count; i++) {
// first, I tried this, but it failed:
// unoArgs[i] = args[i];
// then, I tried this, but it failed trying to call selector `unoObject` on the
// NSString* that was the first element of the array
id<UnoObject> a = args[i];
@{object[]:Of(unoArgs).Set(i, a)};
}
}
// here is where I pass those arguments to the passed in Action
messageHandler(action, unoArgs);
}];
@}
How do I convert that NSArray* provided to the block to an object[] that my Uno Action can handle?