ios - String.Encoding is not getting translated to NSStringEncoding in swift 3 to objective C conversion -


am converting existing swift source code base swift 3 , have method in swift class earlier returning nsstringencoding. in swift 3, compiler asks me convert nsstringencoding string.encoding. method not getting reflected in objective-c's generated interface , not able call method in objective-c classes.

this sample code snippet :

@objc open class myclass: nsobject{     open var textencoding: string.encoding { { return self.getencoding() } }      fileprivate func getencoding() -> string.encoding{         // conversion code         return encoding     } } 

in objective-c class,

-(void)demofunc:(myclass * _nonnull)response{ (i)  nsstringencoding responseencoding = response.textencoding; } 

the compiler throwing error above line,

property 'textencoding' not found on object of type 'myclass *'

how fix issue cannot declare/use nsstringencoding in swift file , in objective c cannot use string.encoding ?

foundation defines

typedef nsuinteger nsstringencoding; ns_enum(nsstringencoding) {     nsasciistringencoding = 1,      /* 0..127 */     // ... }; 

which mapped swift as

extension string {     public struct encoding : rawrepresentable {         public var rawvalue: uint         // ...     } } 

so can pass raw value objective-c:

open var textencoding: uint { return self.getencoding().rawvalue } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -