调用obj C项目的iOS Swift方法

时间:2017-01-16 04:51:33

标签: ios objective-c swift3

我正在使用imglyKit swift 3 library

使用swift示例,我可以使用[从任何地方调用,共享实例?]设置自定义过滤器:              PhotoEffect.allEffects = effects

和效果是一个数组,

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")
]

因此,使用"共享实例"的此配置适用于代码中的任何位置。

现在的问题是,如何访问pod的共享实例" imglykit"为了设置这个属性?

这里是对目标C的测试,但只是一个实例,如何链接已经创建的对象?

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

1 个答案:

答案 0 :(得分:1)

allEffectsIMGLYPhotoEffect类(在Swift中称为PhotoEffect类)的类方法。

试试这个:

IMGLYPhotoEffect.allEffects = effects;

这里有一个提示,用于确定在Objective-C中调用swift API的正确方法:如果你在Objective-C项目中单击符号IMGLYPhotoEffect,它将带你去Objective-C中生成的类的标题。