Giter Site home page Giter Site logo

realm-objectmapper-tutorial's Introduction

Realm + Objectmapper Tutorial

To clone the repository using HTTPS, under "Clone with HTTPS", click . To clone the repository using an SSH key, including a certificate issued by your organization's SSH certificate authority, click Use SSH, then click .

Open Terminal.

Type git clone, and then paste the URL you copied earlier.

$ git clone https://github.com/sarojraut/Test-Project Press Enter. Your local clone will be created.

$ git clone https://github.com/sarojraut/Test-Project

Cloning into Test-Project...

remote: Counting objects: 10, done.

remote: Compressing objects: 100% (8/8), done.

remove: Total 10 (delta 1), reused 10 (delta 1)

Unpacking objects: 100% (10/10), done.

Now, you have a local copy of the Test-Project repository!

XCode Version used 11.1

IOS Deployment target 10.0

realm-objectmapper-tutorial's People

Contributors

sarojraut avatar

Stargazers

Fazle Rabbi Linkon avatar Ruslan Iskhakov avatar

Watchers

James Cloos avatar  avatar

Forkers

lif-wtag

realm-objectmapper-tutorial's Issues

Could not parse properly

I followed your tutorial and inspired. And tried to do the same in a sample project.

I am fetching data from a sample api.: https://www.googleapis.com/books/v1/volumes?q=flowers+inauthor:keyes&key=AIzaSyCXtfir93vgsETeCB8aLFTeuD6xrVxTVvE

and created 3 classes for data parsing:

`class FakeVehicles: Object, Mappable {

var poiList = List<PoiList>()

required convenience init?(map: Map) {
    self.init()
}

// Mappable
func mapping(map: Map) {
    poiList    <- map["poiList"]
}

}`

`
class PoiList: Object, Mappable {

@objc dynamic var coordinate: Coordinate?
@objc dynamic var fleetType: String = ""
@objc dynamic var heading: Float = 0.0
@objc dynamic var id: Int = 0

required convenience init?(map: Map) {
    self.init(map: map)
}

// Mappable
func mapping(map: Map) {
    id          <- map["id"]
    coordinate  <- map["coordinate"]
    fleetType   <- map["fleetType"]
    heading     <- map["heading"]
}

}
`

`
class Coordinate: Object, Mappable {

@objc dynamic var latitude: Float = 0.0
@objc dynamic var longitude: Float = 0.0

required convenience init?(map: Map) {
    self.init()
}

func mapping(map: Map) {
    latitude    <- map["latitude"]
    longitude   <- map["longitude"]
}

}
`

and in worker class i called the api and parsed like:

AF.request(url).responseString { (response) in let jsonString = String(data: response.data!, encoding: .utf8)! let model = FakeVehicles(JSONString: jsonString) print(model?.poiList) }

but its printing as `Optional(List <0x60000225d230> (

))`

I can't figure out where I am making mistake. Please guide me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.