Created
June 27, 2019 17:47
-
-
Save jvcleave/d6f08398c6c599b4dce030a192e83c7c to your computer and use it in GitHub Desktop.
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
import UIKit | |
class Content | |
{ | |
var name:String = "DEFAULT" | |
func setup(_ name:String) | |
{ | |
self.name = name | |
} | |
} | |
class ContentCollection | |
{ | |
var array:[Content] = [] | |
} | |
func printContent(_ contentArray:[Content]) | |
{ | |
for content in contentArray | |
{ | |
print("content.name \(content.name)") | |
} | |
} | |
var contentCollections:[ContentCollection] = [] | |
let collection1 = ContentCollection(); | |
let collection2 = ContentCollection(); | |
contentCollections.append(collection1) | |
contentCollections.append(collection2) | |
var words:[String] = ["is", "this", "copied"] | |
var array:[Content] = [] | |
for word in words | |
{ | |
let content = Content(); | |
content.setup(word) | |
array.append(content) | |
} | |
for contentCollection in contentCollections | |
{ | |
contentCollection.array = array | |
} | |
print("ARRAY1") | |
printContent(contentCollections.first!.array) | |
print("ARRAY2") | |
printContent(contentCollections.last!.array) | |
var omg = Content(); | |
omg.setup("omg") | |
//contentCollections.first!.array.append(omg) <-kill me | |
contentCollections[0].array.append(omg) | |
print("ARRAY1") | |
printContent(contentCollections.first!.array) | |
print("ARRAY2") | |
printContent(contentCollections.last!.array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment