title: Object Mapper/Core Data, object mapper nil value fields
body: <p>I need to save JSON Object retrieved into Core Data using some mapper ( Object Mapper, for example).
  I'm using a rest api that retrieve this json:</p>
  
  <pre><code>[
  {
      "event_id": "1",
      "event_name": "Lungo il tevere",
      "event_image_url": "https:\/\/www.dayroma.it\/wp-content\/uploads\/2016\/06\/event_fb-9400.jpg",
      "event_content": "&lt;b&gt;Lungo il Tevere Roma 2016, bancarelle sulle banchine del Tevere&lt;\/b&gt;\r\n\r\n&amp;nbsp;\r\n\r\n&amp;nbsp;",
      "event_start_date": "2016-07-29",
      "event_end_date": "2016-07-30",
      "event_start_time": "22:00:00",
      "event_end_time": "03:00:00",
      "location_name": "Lungotevere",
      "location_address": "Piazza Navona 2, Roma",
      "location_latitude": "41.897785",
      "location_longitude": "12.472971"
  },
  {
      "event_id": "8",
      "event_name": "test 7 - VIlla BOrghese",
      "event_image_url": "https:\/\/www.dayroma.it\/wp-content\/uploads\/2016\/06\/event_fb-9398.jpg",
      "event_content": "TEst villa borghese",
      "event_start_date": "2016-07-29",
      "event_end_date": "2016-07-30",
      "event_start_time": "22:00:00",
      "event_end_time": "02:00:00",
      "location_name": "Villa Borghese",
      "location_address": "Villa Borghese 4, Roma",
      "location_latitude": "41.912888",
      "location_longitude": "12.485208"
  }
  </code></pre>
  
  <p>]</p>
  
  <p>Nothing special, a simple JSON array.
  I need to parse it into Data Objects and store into Core Data.
  Actually, I have problem about mapping Object into Core Data Object, because only String value are retrieve, the others are nil.</p>
  
  <p>Here my dataController</p>
  
  <pre><code>class DataController: NSObject {
  
  var managedObjectContext: NSManagedObjectContext
  
  override  init() {
      // This resource is the same name as your xcdatamodeld contained in your project.
      guard let modelURL = NSBundle.mainBundle().URLForResource("DataModel", withExtension:"momd") else {
          fatalError("Error loading model from bundle")
      }
      // The managed object model for the application. It is a fatal error for the application not to be able to find and load its model.
      guard let mom = NSManagedObjectModel(contentsOfURL: modelURL) else {
          fatalError("Error initializing mom from: \(modelURL)")
      }
      let psc = NSPersistentStoreCoordinator(managedObjectModel: mom)
      self.managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
      self.managedObjectContext.persistentStoreCoordinator = psc
  
      let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
      let docURL = urls[urls.endIndex-1]
      /* The directory the application uses to store the Core Data store file.
       This code uses a file named "DataModel.sqlite" in the application's documents directory.
       */
      let storeURL = docURL.URLByAppendingPathComponent("DataModel.sqlite")
      do {
          try psc.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeURL, options: nil)
      } catch {
          fatalError("Error migrating store: \(error)")
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>HERE my object core properties:</p>
  
  <pre><code>extension Event {
  
  @NSManaged var eventId: Int
  @NSManaged var eventName: String?
  @NSManaged var eventImageUrl: String?
  @NSManaged var eventContent: String?
  @NSManaged var eventStartTime: NSDate?
  @NSManaged var eventEndTime: NSDate?
  @NSManaged var eventStartDate: NSDate?
  @NSManaged var eventEndDate: NSDate?
  @NSManaged var locationName: String?
  @NSManaged var locationAddress: String?
  @NSManaged var locationLatitude: NSNumber?
  @NSManaged var locationLongitude: NSNumber?
  </code></pre>
  
  <p>}</p>
  
  <p>And here my Core Data Object model that implements mappable:</p>
  
  <pre><code>class Event: NSManagedObject, Mappable {
  
  
  override init(entity: NSEntityDescription, insertIntoManagedObjectContext context: NSManagedObjectContext?) {
      super.init(entity: entity, insertIntoManagedObjectContext: DataController().managedObjectContext)
  }
  
  required init?(_ map: Map) {
      let ctx = DataController().managedObjectContext
      let entity = NSEntityDescription.entityForName("Event", inManagedObjectContext: ctx)
      super.init(entity: entity!, insertIntoManagedObjectContext: ctx)
  
      mapping(map)
  }
  
  func mapping(map: Map) {
  
      eventId   &lt;- map["event_id"]
      eventName   &lt;- map["event_name"]
      eventImageUrl   &lt;- map["event_image_url"]
      eventContent   &lt;- map["event_content"]
      eventStartTime   &lt;- map["event_start_time"]
      eventEndTime   &lt;- map["event_end_time"]
      eventStartDate   &lt;- map["event_start_date"]
      eventEndDate   &lt;- map["event_end_date"]
      locationName   &lt;- map["location_name"]
      locationAddress   &lt;- map["location_address"]
      locationLatitude   &lt;- map["location_latitude"]
      locationLongitude   &lt;- map["location_longitude"]
  
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Running this: </p>
  
  <pre><code>let URL = "##### MY API ######"
      Alamofire.request(.GET, URL).responseArray { (response: Response&lt;[Event], NSError&gt;) in
  
          let eventsArray = response.result.value
  
          for element in eventsArray! {
              print(element)
          }
  
      }
  </code></pre>
  
  <p>I retrieve this:</p>
  
  <pre><code>data: {
  eventContent = "TEst villa borghese";
  eventEndDate = nil;
  eventEndTime = nil;
  eventId = 0;
  eventImageUrl = "https://www.dayroma.it/wp-content/uploads/2016/06/event_fb-9398.jpg";
  eventName = nil;
  eventStartDate = nil;
  eventStartTime = nil;
  locationAddress = "Villa Borghese 4, Roma";
  locationLatitude = nil;
  locationLongitude = nil;
  locationName = "Villa Borghese";
  </code></pre>
  
  <p>}</p>
  
  <p>Great part of fields are nil,
  can you help me to understand what is the problem? </p>
  
  <p>Thank youy</p>