manuelBetancurt
manuelBetancurt

Reputation: 16168

iOS Swift method called on obj C project

I am working with imglyKit swift 3 library

With the swift sample, I can set the custom filters with [called from anywhere, shared instance?]: PhotoEffect.allEffects = effects

and effects is an array,

private let effects: [PhotoEffect] = [
    PhotoEffect(identifier: "None", ciFilterName: nil, lutURL: nil, displayName: "None", options: nil),
    PhotoEffect(identifier: "K1", lutURL: Bundle(for: PhotoEffect.self).url(forResource: "K1", withExtension: "png"), displayName: "K1"),
    PhotoEffect(identifier: "K2", lutURL: Bundle(for: PhotoEffect.self).url(forResource: "K2", withExtension: "png"), displayName: "K2"),
    PhotoEffect(identifier: "K6", lutURL: Bundle(for: PhotoEffect.self).url(forResource: "K6", withExtension: "png"), displayName: "K6"),
    PhotoEffect(identifier: "Dynamic", lutURL: Bundle(for: PhotoEffect.self).url(forResource: "Dynamic", withExtension: "png"), displayName: "Dynamic"),
    PhotoEffect(identifier: "Fridge", lutURL: Bundle(for: PhotoEffect.self).url(forResource: "Fridge", withExtension: "png"), displayName: "Fridge")
]

So this configuration with "shared instance", works anywhere in the code.

Now the question, is how to access the shared instance for the pod "imglykit" in order to set this property?

Here a test on objective C, but is just an instance, how to link with already created object?

    IMGLYPhotoEffect *photoEffect = [[IMGLYPhotoEffect alloc]initWithIdentifier:@"None" ciFilterName:nil lutURL:nil displayName:@"None" options:nil];

Upvotes: 0

Views: 60

Answers (1)

Jon Brooks
Jon Brooks

Reputation: 2492

allEffects is a class method on the IMGLYPhotoEffect class (which is called PhotoEffect class in Swift).

Try this:

IMGLYPhotoEffect.allEffects = effects;

Here's a tip for figuring out the proper way to call swift APIs when in Objective-C: If you Cmd-Click the symbol IMGLYPhotoEffect while in your Objective-C project, it will take you to a generated header of the class in Objective-C.

Upvotes: 1

Related Questions