Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d53a984
Showing
27 changed files
with
3,399 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
|
||
*.DS_Store | ||
|
||
ModelRocket.framework.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: objective-c | ||
osx_image: xcode6.4 | ||
script: | ||
- xcodebuild -project ModelRocket.xcodeproj -scheme ModelRocket -sdk iphonesimulator8.4 test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015 Oven Bits, LLC | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import ModelRocket | ||
|
||
/*: | ||
The **Vehicle** object has four properties, one of | ||
which is required (when using the `strictJSON` initializer). | ||
The underlying value on `Property` is always Optional. However, if the property | ||
is required and the `strictJSON` initializer is used, `value` can be force | ||
unwrapped safely, since the object will be created iff all properties where | ||
`required == true` are found in the JSON object | ||
*/ | ||
|
||
class Vehicle: ModelRocket { | ||
let model = Property<String>(key: "model") | ||
let year = Property<Int>(key: "year") | ||
let color = Property<UIColor>(key: "color") | ||
let availableColors = PropertyArray<UIColor>(key: "available_colors") | ||
let availableTrims = PropertyDictionary<Int>(key: "available_trims") | ||
/*: | ||
If you would like to avoid the use of `.value` to retrieve | ||
the underlying value of a `Property`, a good pattern to use | ||
is defining the `Property<T>` property as `private` (prefixed with a _) | ||
and declaring a separate, `public` property of type `T` | ||
*/ | ||
private let _make = Property<String>(key: "make", required: true) | ||
var make: String { | ||
set { _make.value = newValue } | ||
get { return _make.value ?? "" } | ||
} | ||
} | ||
|
||
let json = JSON(data: dataFromResource()) | ||
if let vehicle = Vehicle(strictJSON: json) { | ||
vehicle.make | ||
vehicle.model.value | ||
vehicle.year[] | ||
|
||
for color in vehicle.availableColors { | ||
println("Color: \(color)") | ||
} | ||
|
||
for (key, value) in vehicle.availableTrims { | ||
println("Trim \(key) : \(value)") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"make" : "BMW", | ||
"model" : "M5", | ||
"year" : 2015, | ||
"color" : "#132F5B", | ||
"available_colors" : [ | ||
"#FF0000", | ||
"#00FF00", | ||
"#0000FF" | ||
], | ||
"available_trims" : { | ||
"sedan" : 1024, | ||
"gran-turismo" : 512 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// This file (and all other Swift source files in the Sources directory of this playground) will be precompiled into a framework which is automatically made available to ModelRocket.playground. | ||
// | ||
|
||
import Foundation | ||
|
||
public func dataFromResource() -> NSData { | ||
let jsonPath = NSBundle.mainBundle().pathForResource("TestJSON", ofType: "json") | ||
let jsonData = NSData(contentsOfFile: jsonPath!) | ||
|
||
return jsonData! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<playground version='5.0' target-platform='ios'> | ||
<timeline fileName='timeline.xctimeline'/> | ||
</playground> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Timeline | ||
version = "3.0"> | ||
<TimelineItems> | ||
</TimelineItems> | ||
</Timeline> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "ModelRocket" | ||
s.version = "1.0" | ||
s.license = "MIT" | ||
s.summary = "An iOS framework for creating JSON-based models. Written in Swift." | ||
s.homepage = "https://github.com/ovenbits/ModelRocket" | ||
s.author = { "Jonathan Landon" => "jonathan.landon@ovenbits.com" } | ||
s.source = { :git => "https://github.com/ovenbits/ModelRocket.git", :tag => s.version.to_s } | ||
s.platform = :ios, '8.0' | ||
s.requires_arc = true | ||
s.source_files = ['ModelRocket/*.swift', 'ModelRocket/*.h'] | ||
end |
Oops, something went wrong.