aryaxt / OCMapper

Objective-C library to easily map NSDictionary to model objects, works perfectly with Alamofire. ObjectMapper works similar to GSON
MIT License
347 stars 45 forks source link

Not Working in Swift 2.0 #38

Closed dhavalgolakiya closed 8 years ago

dhavalgolakiya commented 9 years ago

Hi I'm using OCMapper in swift 1.2 and it is working correctly. But migrating to swift 2.0, it gives nil object.

In My Object

public class Response: NSObject {

    var flag = false
    var message : String?
    var announcement : String?
    var data : User?
}

public class User : Object  {

    dynamic var id = ""
    dynamic var imgName = ""
    dynamic var imageUrl = ""
    dynamic var mobile = ""
    dynamic var firstName = ""
    dynamic var lastName = ""
    dynamic var email = ""
}

User is a Realm Object. When I map object from dictionary

 let response = dictionary?.toClass(Response.self)

or

let user = ObjectMapper.sharedInstance().objectFromSource(dictionary, toInstanceOfClass: Response.self) as? Response

Response gives data = nil and mapping failed. It is working in Swift 1.2 so any issue of OCMapper with Swift 2.0 or any update for it?

aryaxt commented 9 years ago

Will look into this today, Can you provide more info:

dhvlgolakiya commented 8 years ago

Hi, I'm using OCMapper- version 2.1 iOS 9 and Xcode 7

This is completely working in iOS 8.4 and Xcode 6.4 with Swift 1.2. But getting issue in iOS 9 and Xcode 7 with Swift 2.0.

aryaxt commented 8 years ago

Can you provide any sample code? I converted my project to swift 2.0 and running on xcode7 everything works as expected