ios - Swift - Bridging header failed. '*' does not have a member named '*' -


i develop app using commoncrypto library. problem can create instance in swift file. object created using objective- c. seems can't create bridging header well.

error message

/users/mnurdin/documents/ios/xxxxx/models/main.swift:15:9: 'customobject' not have member named 'encrypt' 

customobject.h

#import <foundation/foundation.h> #import <commoncrypto/commoncrypto.h> #import "gtmbase64.h"  @interface customobject : nsobject + (nsstring*)encrypt:(nsstring*)plaintext withkey:(nsstring*)key; @end 

customobject.m

#import "customobject.h" @implementation customobject + (nsstring*)encrypt:(nsstring*)plaintext withkey:(nsstring*)key{     /*--*/     return result; } @end 

global.swift

var instanceofcustomobject: customobject = customobject() println(instanceofcustomobject.encrypt("p@$$w0rd","12345678")) 

please advice. thank you.

the initial + in declaration indicates that

+ (nsstring*)encrypt:(nsstring*)plaintext withkey:(nsstring*)key; 

is class method in objective-c. have call on class (or type in swift linguage) itself, not on instance:

let encrypted = customobject.encrypt("p@$$w0rd", withkey: "12345678") 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -