Skip to content

Commit 3b8654a

Browse files
committed
Swift dictionary example code added
1 parent 0230529 commit 3b8654a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
line-height: inherit;
1111
}
1212

13-
pre { display: block; padding: 0.5em; color: #333; background: #f8f8ff; border: 1px solid #ccc; border-radius: 4px; }
13+
pre {-moz-tab-size: 4; tab-size: 4; display: block; padding: 0.5em; color: #333; background: #f8f8ff; border: 1px solid #ccc; border-radius: 4px; }

languages/SwiftDictionary.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,6 @@
143143
"checked": "checked"
144144
}
145145
}
146-
}
146+
},
147+
"exampleCode": "## Example\n\n\n#### Decoding:\nThe example below shows how to decode an instance of `<!RootClassName>` type from JSON object.\n\n```swift\nlet json = \"\"\"\n<!JsonString>\n\"\"\".data(using: .utf8)!\n\ndo { \n\tif let dict = try JSONSerialization.jsonObject(with: json, options: .allowFragments) as? [String: Any] {\n\t\tlet model = <!RootClassName>(dict) \n\t}\n} catch { \n\t// Handle error \n}\n```\n\n\n#### Encoding: \nThe example below shows how to encode an instance of a simple `<!RootClassName>` type into a JSON object.\n>Make sure to check `toDictionary()` method.\n```swift\nlet model = <!RootClassName>()\n// Assign value to properties.\n\nlet dict = model.toDictionary()\ndo {\n\tlet data = try JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted)\n\tprint(String(data: data, encoding: .utf8)!)\n} catch {\n\t// Handle Error\n}\n```"
147148
}

0 commit comments

Comments
 (0)