Thanks Quincey
1. By a "bridge file", I mean the bridging header file that is needed to call an Objective-C function in Swift.
Here is the content of the bridging header file, where I import "PinterestSDK/PDKClient.h", allowing me to reference the Objective-c function it contains from Swift
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//
#ifndef MyApp_Bridging_Header_h
#define MyApp_Bridging_Header_h
#import "PinterestSDK/PDKClient.h"
#endif / MyApp_Bridging_Header_h */
2. Here is the definition of the objective-c function in the .h file: Note that the "fields" parameter is used to return data from the api
This is the value that I am having problems referencing in Swift.
/*
* Get a list of the authorized user's boards. The reponse can be used to
* get the next page of boards.
*
* @param fields The board fields that will be returned by the api
* @param successBlock Called when the API call succeeds
* @param failureBlock Called when the API call fails
*/
- (void)getAuthenticatedUserBoardsWithFields:(NSSet *)fields
success:(PDKClientSuccess)successBlock
andFailure:(PDKClientFailure)failureBlock;
3. Here is the actual objective-c function in the .m file:
- (void)getAuthenticatedUserBoardsWithFields:(NSSet *)fields
success:(PDKClientSuccess)successBlock
andFailure:(PDKClientFailure)failureBlock
{
NSDictionary *parameters = @{@"fields" : [[fields allObjects] componentsJoinedByString:@","]};
[self getPath:@"me/boards/" parameters:parameters withSuccess:successBlock andFailure:failureBlock];
}
4. Here my Swift code where i am trying to use the Objective-C function. XCode is suggesting tha I define the "withFields" parameter as a Set<AnyHashable>.
PDKClient.sharedInstance().getAuthenticatedUserBoards(withFields: Set<AnyHashable>,
success: PDKClientSuccess!,
andFailure: PDKClientFailure!)
Note that I need to provide 3 values, the last 2 are just closures to be invoked on success and failure. The problem I have is with the 1st parameter, which will be used to return data from the call.
I don't know how to define the 1st parameter in Swift.
Thanks