Skip to content

Instantly share code, notes, and snippets.

@jvcleave
Created June 27, 2019 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvcleave/d6f08398c6c599b4dce030a192e83c7c to your computer and use it in GitHub Desktop.
Save jvcleave/d6f08398c6c599b4dce030a192e83c7c to your computer and use it in GitHub Desktop.
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