<commit_before>---
layout: post
title: "Model Class"
categories: objc-reference
---

#### JSON Schema to Objective-C type mapping

| Schema Property Type                | Objective-C Type                                               |
| :--- | :--- |
| String                              | `NSString`                                                       |
| Boolean                             | `BOOL`                                                     |
| Integer                             | `NSInteger`                                                      |
| Number                              | `double`                                                         |
| Date-time Property (String variant) | `NSDate`                                                         |
| String Property                     | `NSString` |
| URI Property (String variant)       | `NSURL`                                                          |
| JSON Pointer Property (`$ref`)        | ModelType                                                      |
| Array Property                      | `NSArray`                                                        |
| Array Property with Item types      | `NSArray<ModelType *>`  |
| Object Property                     | `NSDictionary`                         |
| Object Property with item types     | `NSDictionary<NSString *, ModelType *>`                          |
| Algebraic Data Type (`oneOf`)       | ADT Class (ModelType + Property name)                          |


#### Generated Methods
<pre><code class="objc">@interface User : NSObject<NSCopying, NSSecureCoding>

+ (NSString *)className;
+ (NSString *)polymorphicTypeIdentifier;

// Initialization (JSON Parsing)
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dictionary;
- (instancetype)initWithModelDictionary:(NSDictionary *)modelDictionary;
<commit_msg>Update 2017-02-10-objc-overview.md<commit_after>---
layout: post
title: "Model Class"
categories: objc-reference
---

#### JSON Schema to Objective-C type mapping

| Schema Property Type                | Objective-C Type                                               |
| :--- | :--- |
| Boolean                             | `BOOL`                                                     |
| Integer                             | `NSInteger`                                                      |
| Number                              | `double`                                                         |
| String Property                     | `NSString` |
| Date-time Property (String variant) | `NSDate`                                                         |
| URI Property (String variant)       | `NSURL`                                                          |
| JSON Pointer Property (`$ref`)        | ModelType                                                      |
| Array Property                      | `NSArray`                                                        |
| Array Property with Item types      | `NSArray<ModelType *>`  |
| Object Property                     | `NSDictionary`                         |
| Object Property with item types     | `NSDictionary<NSString *, ModelType *>`                          |
| Algebraic Data Type (`oneOf`)       | ADT Class (ModelType + Property name)                          |


#### Generated Methods
<pre><code class="objc">@interface User : NSObject<NSCopying, NSSecureCoding>

+ (NSString *)className;
+ (NSString *)polymorphicTypeIdentifier;

// Initialization (JSON Parsing)
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dictionary;
- (instancetype)initWithModelDictionary:(NSDictionary *)modelDictionary;

{'fraction_non_alphanumeric': 0.0912568306010929, 'fraction_numerical': 0.002185792349726776, 'mean_word_length': 1.0104338275672706, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1353593', 'n_tokens_mistral': 759, 'n_tokens_neox': 702, 'n_words': 181}