Skip to content

Commit

Permalink
dataWithoutMaterial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dariukas committed Apr 15, 2017
1 parent 03bbfed commit 0b4c8d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
17 changes: 12 additions & 5 deletions 5DPlannerTask/Models/Item.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ class Item: DataExtractProtocol {
var items: [[String: AnyObject]]?
var materials: Materials?

init(item: [String : AnyObject]) {
// super.init()
if let items = extractData(input: item, using: "items") as? [[String: AnyObject]] {
init(data: [String : AnyObject]) {
// super.init() in the case NSObject
if let items = extractData(input: data, using: "items") as? [[String: AnyObject]] {
self.items = items
}
if let materials = extractData(input: item, using: "materials") as? [String: AnyObject] {
if let materials = extractData(input: data, using: "materials") as? [String: AnyObject] {
self.materials = Materials(materials)
}
}

init(dataWithoutMaterial: [String : AnyObject]) {
// super.init()
if let items = extractData(input: dataWithoutMaterial, using: "items") as? [[String: AnyObject]] {
self.items = items
}
}
}

class Project: Item {
Expand All @@ -30,7 +37,7 @@ class Project: Item {
var height: Float?
var ground: Material?

func extract(data: [String: AnyObject]) {
func extract(_ data: [String: AnyObject]) {
if let width = extractData(input: data, using: "width") as? Float {
self.width = width
}
Expand Down
14 changes: 6 additions & 8 deletions 5DPlannerTask/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,20 @@ class ViewController: UIViewController {


func run() {

let data: [String : AnyObject]=[:]

//let data: [String : AnyObject]=[:]
let input = JSONData.parseJSON(fileName: "JSONData")
let json = JSON(input: input)
let project = Project(item: json.data!)
project.extract(data: json.data!)
let project = Project(dataWithoutMaterial: json.data!)
project.extract(json.data!)

for item in project.items! {
let floor = Floor(item: item)
let floor = Floor(dataWithoutMaterial: item)
floor.extract(item)
for item in floor.items! {
let room = Room(item: item)
let room = Room(data: item)
room.extract(item)
for item in room.items! {
let wall = Wall(item: item)
let wall = Wall(data: item)
wall.extract(item)
}
}
Expand Down

0 comments on commit 0b4c8d0

Please sign in to comment.