https://github.com/geri-borbas/ios.library.eppz_model
A model layer for the everydays. Extreme simplicity (while fully customizable).
https://github.com/geri-borbas/ios.library.eppz_model
Last synced: about 2 months ago
JSON representation
A model layer for the everydays. Extreme simplicity (while fully customizable).
- Host: GitHub
- URL: https://github.com/geri-borbas/ios.library.eppz_model
- Owner: Geri-Borbas
- Created: 2014-05-01T18:05:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-05-21T01:08:03.000Z (almost 11 years ago)
- Last Synced: 2025-01-17T16:16:28.499Z (3 months ago)
- Language: Objective-C
- Homepage:
- Size: 1.08 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## **eppz!model**
**A model layer for the everydays.** Extreme simplicity (while fully customizable).
```Objective-C
// Just add `` to your existing model(s)
@interface ComplexStuff
// Various properties, containing references to / collections of other models
@end// On monday.
NSDictionary *representation = [complexStuff dictionaryRepresentation];// Two days later.
ComplexStuff *complexStuff = [ComplexStuff instanceWithDictionary:representation];```
Basically eppz!model is designed for **network usage**, to represent complex entities / object graphs
(probably in an `NSDictionary` / `JSON` output), and also reconstruct runtime objects from a network
responses (probably `JSON`). Later on I'll open the source that works with `CoreData`, and sync (based
on last modification date) stuff as well.Though, it can be use as **object formatter** for example, supposing you're designed an [MVVM](https://en.wikipedia.org/wiki/Model_View_ViewModel)
architecture, it can be a flexible formatting layer in your view model conversions. Value / field
mappers can be plugged in at runtime to fit every need.> #### Basic usage
> Represent an object.
> #### Custom field mapping
> Map runtime property names to custom field names in representation.
> #### Custom value mapping
> Customize value representing / reconstruction in different fields.
> #### Represent foreign classes
> Represent / reconstruct a `UIView`.
> #### Save representations
> Save to `plist`, archive (automatic ``) and more.
> #### Represent cross-references
> See cross-references being represented / reconstructed.
> #### Goodies
> Property inspection, collection tools, handy macros.
> #### Examples (test suites)
> See every feature in action in test suites.## Names
Some library notions you can bump into while browsing class headers:
> * **Field**
> + is actually a property name
> * **Field mapper**
> + converts runtime property names to representation property names (and vica-versa)
> * **Value mapper**
> + converts runtime values to representation values (and vica-versa)
> * **Mapper**
> + is an object containing a field mapper, value mappers and some additional mapping property (like dateFormatter).## Basic usage
If you just need a dictionary representation of an object, or object graph, you can simply mark the model as an ``, and done.
```Objective-C
// Model.
// Dictionary.
// Result.
```The basic value mapper beside basic Foundation classes can represent `NSData` (as Base64 string), `NSDate` (using a default formatter, or your own), `CGPoint`, `CGSize`, `CGRect`, `CGAffineTransform`.
### Custom field mapping
+ Field is a property, value is a value
+ Convert
+ Mask### Custom value mapping
+ Per field
+ Different color representations### Represent foreign classes
+ Represent `UIView`
### Save representations
+ `JSON`
+ `plist`
+ `NSUserDefaults`
+ `` (automatic)### Represent cross-references
+ Player / GameProgress / Achivement example
### Goodies (property inspection, collection tools, handy macros)
+ Property inspection
+ Collection operators
+ Handy macros (`FORMAT`, `WEAK_SELF`)### Configure unknown objects
+ SpriteKit `SKSpriteNode` configuration example
### Examples (test suites)
Browsing test cases can tell you the most about every aspect of the library, it is actually almost 100% covered.
### License
+ MIT