I have a library function written in Objective C that has takes a pointer to a NSMutableArray. However, when I try to call it with a Swift array I get this error:
DiscoverViewController.swift:34:20: Could not find an overload for 'init' that
accepts the supplied arguments
However, if I pass nil, it works. That makes sense.
Here is an example of the Objective-C:
int ex:(NSMutableArray *)in { return in.count; }
And an example of the Swift:
ex([1,2,3,4]) // doesn't compile
ex(nil) // does compile
What do I have to do to convert/cast the Swift array to the NSMutableArray type that my library function is looking for?
Here is the full method signature in case my example is too simplified:
- (id) initWithTitle: (NSString *) title place: (PublicPlaceInfo *) place
datetimeInterval: (DateTimeInterval *) datetimeInterval costBracket: (int)
costBracket creatorId: (PersonID) creatorId cover: (Url) cover experienceId:
(ExperienceID) experienceId numJoined: (int32_t) numJoined relatedJoined:
(NSMutableArray *) relatedJoined;
And then I know it is failing at the relatedJoined section because I converted all other potentially anonymous instantiations to variables. I have to say, this is certainly not the most helpful compile error..