Laxsnor
Laxsnor

Reputation: 857

Implementing Methods from Objective C Library with Swift

I am trying to implement the following method in swift:

From the class FLIROneSDKImageReceiverDelegate, which is subclassed inside my ViewController class as so:

class ViewController: UIViewController, FLIROneSDKImageReceiverDelegate,
    FLIROneSDKStreamManagerDelegate,
                        FLIROneSDKImageEditorDelegate{

Note that I have already created a bridging header etc.

In the FLIROneSDKImageReceiverDelegate header file:

- (void) FLIROneSDKDelegateManager:(FLIROneSDKDelegateManager *)delegateManager didReceiveBlendedMSXRGBA8888Image:(NSData *)msxImage imageSize:(CGSize)size;

Am I wrong in thinking that this is the correct way to implement this function?

func FLIROneSDKDelegateManagerdidReceiveBlendedMSXRGBA8888ImageimageSize(delegateManager: FLIROneSDKDelegateManager!, msxImage: NSData, size: CGSize){

Note that FLIROneSDKDelegateManager is a class.

Upvotes: 1

Views: 322

Answers (2)

Simon Pickup
Simon Pickup

Reputation: 892

@Laxsnor's solution in the comments on the answer by @aaron-wojnowski helped me too, thanks both.

To consolidate:

The problem is a conflict created by the name FLIROneSDKDelegateManager being used as a both a class name and a function name - which seems to be OK in Objective-C but not in Swift.

Replacing the class FLIROneSDKDelegateManager with NSObject in the function parameter seems to solve the problem without side-effects. This has to be done in both the Objective-C protocol header file and the Swift delegate class source file.

NOTE I also found this same solution applied more broadly to Swift-ify the entire FLIROneSDK at https://github.com/jruhym/flirmebaby.

Happy developing for FLIROne on Swift. (I'm new to FLIROne and relatively new to Swift so apologies if my language isn't quite precise enough.)

Upvotes: 0

Aaron Wojnowski
Aaron Wojnowski

Reputation: 6480

Off the top of my head, but try this:

func FLIROneSDKDelegateManager(delegateManager: FLIROneSDKDelegateManager!, didReceiveBlendedMSXRGBA8888Image msxImage: NSData!, imageSize size: CGSize) {

    // method imp

}

Upvotes: 1

Related Questions