我开发了一个使用 CommonCrypto 库的应用程序。问题是我可以在 Swift 文件中创建一个实例。我的对象是使用 Objective-C 创建的。似乎不能很好地创建桥接头。
错误信息
/Users/MNurdin/Documents/iOS/xxxxx/Models/Main.swift:15:9: 'CustomObject' does not have a member named 'encrypt'
自定义对象.h
#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonCrypto.h>
#import "GTMBase64.h"
@interface CustomObject : NSObject
+ (NSString*)encrypt:(NSString*)plainText withKey:(NSString*)key;
@end
自定义对象.m
#import "CustomObject.h"
@implementation CustomObject
+ (NSString*)encrypt:(NSString*)plainText withKey:(NSString*)key{
/*--*/
return result;
}
@end
全球.swift
var instanceOfCustomObject: CustomObject = CustomObject()
println(instanceOfCustomObject.encrypt("p@$$w0rd","12345678"))