I have to translate the following lines of Objective-c code into swift. This is a sample from the Objective-c JSONModel-Framework where the Optional
protocol provided by the Framework is applied to an instance variable of type NSString
. I found a related post but i didn't managed to achieve it. With my MYModel.swift
implementation Xcode complains Cannot specialize non-generic type NSString
thx for your help!
MYModel.swift
@objc(MYModel) public class MYModel : JSONModel {
...
public var name : NSString<Optional>
...
}
MYModel.h
@interface MYModel : JSONModel
...
@property (strong, nonatomic) NSString<Optional>* name;
...
...
/**
* Protocol for defining optional properties in a JSON Model class. Use like below to define
* model properties that are not required to have values in the JSON input:
*
* @property (strong, nonatomic) NSString<Optional>* propertyName;
*
*/
@protocol Optional
@end
...