{"id":17216892,"url":"https://github.com/nikkovios/objectmapper_realmswift","last_synced_at":"2025-04-13T23:22:56.479Z","repository":{"id":62449487,"uuid":"82310231","full_name":"NikKovIos/ObjectMapper_RealmSwift","owner":"NikKovIos","description":"Helps to parse RealmSwift's List\u003cClass\u003e() and RealmOptional\u003cT\u003e() properties with ObjectMapper framework.","archived":false,"fork":false,"pushed_at":"2019-03-08T13:49:42.000Z","size":10,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T20:53:47.601Z","etag":null,"topics":["objectmapper","realmswift-utilities"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NikKovIos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-17T15:26:48.000Z","updated_at":"2019-03-08T13:49:44.000Z","dependencies_parsed_at":"2022-11-02T01:01:19.860Z","dependency_job_id":null,"html_url":"https://github.com/NikKovIos/ObjectMapper_RealmSwift","commit_stats":null,"previous_names":["nikkovios/objectmapper-realmswift"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikKovIos%2FObjectMapper_RealmSwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikKovIos%2FObjectMapper_RealmSwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikKovIos%2FObjectMapper_RealmSwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NikKovIos%2FObjectMapper_RealmSwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NikKovIos","download_url":"https://codeload.github.com/NikKovIos/ObjectMapper_RealmSwift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248795178,"owners_count":21162725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["objectmapper","realmswift-utilities"],"created_at":"2024-10-15T03:42:38.962Z","updated_at":"2025-04-13T23:22:56.455Z","avatar_url":"https://github.com/NikKovIos.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObjectMapper_RealmSwift\n\n![Cocoapods](https://img.shields.io/badge/pod-available-brightgreen.svg?style=flat)\n![Platform](https://img.shields.io/badge/platform-ios-blue.svg?style=flat)\n![Version](https://img.shields.io/badge/version-0.1.0-blue.svg?style=flat)\n![Swift version](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)\n![License](https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat)\n \n## Installation\n\nObjectMapper_RealmSwift is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'ObjectMapper_RealmSwift'\n```\n\n## Example\n\nHere is the sample code how to use it. Assume you have installed RealmSwift and ObjectMapper. Next step to create realm object. \n\n### Json you get\n ```json\n {\n    \"id\": 12,\n    \"email\": \"hackall@gmail.com\",\n    \"phone\": \"+79996663213\",\n    \"firstName\": \"Mark\",\n    \"lastName\": null,\n    \"privateInfo\": {\n      \"city\": {\n          \"id\": 1,\n          \"value\": \"Vice City\"\n        },\n      \"emails\": [\n        {\n          \"id\": 22,\n          \"value\": \"gdeeqq@hrrrd.dj\"\n        }\n      ],\n      \"country\": {\n        \"id\": 1,\n          \"value\": \"Calefornication\"\n        },\n      \"birthday\": 1042070400\n    },\n    \"socialMedia\": {\n    \"messengers\": [\n      {\n        \"name\": \"one\",\n        \"userId\": \"+79997776666\",\n        \"userName\": \"+79998887777\"\n      },\n      {\n        \"name\": \"two\",\n        \"userId\": \"3456622\",\n        \"userName\": \"megaCoolGuy\",\n        \"userPhone\": \"+79995663322\"\n      }\n    ],\n    \"socialNetworks\": [\n      {\n        \"name\": \"first\",\n        \"userId\": \"31515121221\",\n        \"userName\": \"Yellow Duck\"\n      },\n      {\n        \"name\": \"second\",\n        \"userId\": \"32532523532\",\n        \"userName\": \"Luckky\"\n      }\n    ],\n   \"timeOfPhotoUpload\": 1485442694,\n   \"avatarUrl\": \"http://any_link.com/hot_girl.png\",\n }\n```\n\n### Here is the model\nAccording to https://realm.io/docs/swift/latest/#cheatsheet don't forget `dynamic` and `let` where it is nessesary.\n```swift\nimport RealmSwift\nimport ObjectMapper\nimport ObjectMapper_RealmSwift\n\nclass UserProfile: Object, Mappable {\n  let id = RealmOptional\u003cInt\u003e()\n  dynamic var email: String? = nil\n  dynamic var phone: String = \"\"\n  dynamic var firstName: String? = nil\n  dynamic var lastName: String? = nil\n  dynamic var privateInfo: PrivateInfo?\n  let socialMedia = List\u003cMessenger\u003e()\n  let socialNetworks = List\u003cSocialNetwork\u003e()\n  let timeOfPhotoUpload = RealmOptional\u003cDouble\u003e()\n  dynamic var avatarUrl: String? = nil\n  \n  required convenience init?(map: Map) {\n    if\n        !map[\"id\"].isKeyPresent ||\n        !map[\"phone\"].isKeyPresent\n    {\n      print(\"Can't parse profile info\")\n      return nil\n    }\n    self.init()\n  }\n  \n  override class func primaryKey() -\u003e String? {\n    return \"id\"\n  }\n  \n  func mapping(map: Map) {\n    id                \u003c- map[\"id\"]\n    email             \u003c- map[\"email\"]\n    phone             \u003c- map[\"phone\"]\n    firstName         \u003c- map[\"firstName\"]\n    lastName          \u003c- map[\"lastName\"]\n    privateInfo       \u003c- map[\"privateInfo\"]\n    socialMedia       \u003c- map[\"socialMedia\"]\n    socialNetworks    \u003c- map[\"socialNetworks\"]\n    timeOfPhotoUpload \u003c- (map[\"privateInfo\"], DateTransform())\n    avatarUrl         \u003c- map[\"avatarUrl\"]\n  }\n}\n```\n\nand nested classes: \n\n```swift\nclass Messenger: Object, Mappable {\n  dynamic var name: String? = \"\"\n  dynamic var userID: String? = \"\"\n  dynamic var userName: String? = \"\"\n  \n  required convenience init?(map: Map) {\n    self.init()\n  }\n  \n  func mapping(map: Map) {\n    name            \u003c- map[\"name\"]\n    userID          \u003c- map[\"userId\"]\n    userName        \u003c- map[\"userName\"]\n  }\n}\n```\n```swift\nclass PrivateInfo: Object, Mappable {\n  dynamic var city: Item?\n  let emails = List\u003cItem\u003e()\n  dynamic var country: Item?\n  var birthday = RealmOptional\u003cDouble\u003e()\n  \n  required convenience init?(map: Map) {\n    self.init()\n  }\n  \n  func mapping(map: Map) {\n    city              \u003c- map[\"city\"]\n    emails            \u003c- map[\"emails\"]\n    country           \u003c- map[\"country\"]\n    birthday          \u003c- (map[\"birthday\"], DateTransform())\n  }\n}\n```\n\n## Took from\n\nhttps://gist.github.com/danilValeev/ef29630b61eed510ca135034c444a98a\n\n## License\n\nObjectMapper_RealmSwift is available under the MIT license. See the LICENSE file for more info.\n\n## My other Repos\n\n- [x] https://github.com/NikKovIos/SDWebImage-CircularProgressView - extension to change progress bar on images for SDWebImage\n- [x] https://github.com/NikKovIos/NKVPhonePicker - UITextField subclass picker for country phone codes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikkovios%2Fobjectmapper_realmswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikkovios%2Fobjectmapper_realmswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikkovios%2Fobjectmapper_realmswift/lists"}