Im a rookie in Swift and Objective-C but Im trying to make a bridge from React Native to Swift, and send a JSON and a JSON Array as params to Swift.
Inside React I would like to call this function:
startTrack('some url string', { artist: 'Bruce Springsteen', title: 'Born in the USA' }, [{ url: 'url', type: 'image' }, { url: 'another url', type: 'link' ]})
So a string, an object, and a object array.
In my bridge objective-c file i have this:
RCT_EXTERN_METHOD(startTrack:(NSString *)url trackinfo:(NSDictionary *)trackinfo slides:(NSDictionaryArray *)slides)
And in my swift file i have tried a lot of combinations but nothing seems to go through:
@objc func startTrack(url: String, trackinfo: [String: Any], slides: [[String: Any]]) {
print("Play test", url, trackinfo, slides)
}
How can I send my params all the way through to my Swift file?
Thanks
/Peter
trackInfo:(NSDictionary *)trackInfo
. In swift 3 this parameter would convert to,trackInfo trackInfo: [String: Any]
-- This may be your issue. – AvaRCT_EXTERN_METHOD(startTrack:(NSString *)url withTrackinfo:(NSDictionary *)trackinfo withSlides:(NSDictionaryArray *)slides)
and@objc func startTrack(_ url: String,withTrackInfo trackinfo: [String: Any],withSlides slides: [[String: Any]])
– Ava