TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by FrogRain.
SuperSimpleMapper is just a simple utility to map object of one type to object of another type. Useful if you are using an ORM and feel the need to map to plain objects your ORM objects to prevent complex objects polluting all layers of your app. It also works as json mapper but there’s lot’s of better solutions for that purpose. .
To run the example project, clone the repo, and run pod install
from the Example directory first.
No special requirements
SuperSimpleMapper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "SuperSimpleMapper"
Given this object:
import Foundation
class CoreDataExample {
var title:String?
var text:String?
}
class Example {
var exampleTitle:String?
var textContent:String?
}
Define a location in your app to put all mappings. You can define as many as you need. In this case between CoreDataExample and Example object:
import Foundation
Mapper.createMap { (complexExample: CoreDataExample) -> Example in
let example = Example()
example.exampleTitle = complexExample.title
example.textContent = complexExample.text
return example
}
import Foundation
if let result = Mapper.map(source: ComplextComment()) as Comment? {
//mission complete!!!
}
Take a look at Unit Test classes to figure out other use cases
FrogRain, [email protected]
SuperSimpleMapper is available under the MIT license. See the LICENSE file for more info.