evermeer / EVReflection

Reflection based (Dictionary, CKRecord, NSManagedObject, Realm, JSON and XML) object mapping with extensions for Alamofire and Moya with RxSwift or ReactiveSwift
Other
965 stars 119 forks source link

I'm using the description key which is getting from google api's but there will be the error when I'm using the description key as a string, how Can I fix it please suggest me ? #284

Closed saikishoreagrapalem closed 6 years ago

saikishoreagrapalem commented 6 years ago

public class Descript: EVObject {

var description: String?  -- Error Code ////////////////////////
var icon: String?

override public func propertyMapping() -> [(keyInObject: String?, keyInResource: String?)] {
    return [(keyInObject: "ignoredProperty",keyInResource: nil), (keyInObject: "propertyInObject",keyInResource: "keyInJson")]
}

}

Following error are below I have mentioned

  1. Getter for 'description' with Objective-C selector 'description' conflicts with getter for 'description' from superclass 'NSObject' with the same Objective-C selector

2.Overriding var must be as accessible as its enclosing type

3.Property 'description' with type 'String!' cannot override a property with type 'String'.

Suggest Me How can I Fix this error ???????

evermeer commented 6 years ago

description is one of the reserved keywords. There is a default workaround available for that. Just name your property in the object with an underscore in front of it. EVReflection will then automatically do the mapping for your. Alternatively you could use whatever name you like and add a propertyMapping for that (see propertyMapping in the readme)

Other reserved keywords are: "self", "description", "class", "deinit", "enum", "extension", "func", "import", "init", "let", "protocol", "static", "struct", "subscript", "typealias", "var", "break", "case", "continue", "default", "do", "else", "fallthrough", "if", "in", "for", "return", "switch", "where", "while", "as", "dynamicType", "is", "new", "super", "Self", "Type", "COLUMN", "FILE", "FUNCTION", "LINE", "associativity", "didSet", "get", "infix", "inout", "left", "mutating", "none", "nonmutating", "operator", "override", "postfix", "precedence", "prefix", "right", "set", "unowned", "unowned", "safe", "unowned", "unsafe", "weak", "willSet", "private", "public", "internal", "zone"