Created
June 3, 2015 08:43
-
-
Save Dunemaster/08e3b92e1fdbbaa62a9f 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
// | |
// ViewController.swift | |
// ManyButtons | |
// | |
// Created by Vasiliy Kudryavtsev on 29.05.15. | |
// Copyright (c) 2015 1C. All rights reserved. | |
// | |
import UIKit | |
class TestClass { | |
var integerValue : Int = 0; | |
var stringValue: String = ""; | |
var referenceValue : TestClass?; | |
var referenceValue2 : TestClass?; | |
var arrayValue: [Int] = []; | |
} | |
class ViewController: UIViewController { | |
@IBOutlet weak var myButton: UIButton! | |
@IBOutlet weak var clearButton: UIButton! | |
@IBOutlet weak var label: UILabel! | |
var testObjects: [TestClass] = [] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
@IBAction func onTouchUpInside(sender: AnyObject) { | |
testObjects.reserveCapacity(100000); | |
for var i = 0; i < 100000; i += 1 { | |
var currentObject = TestClass(); | |
currentObject.integerValue = i; | |
currentObject.stringValue = "String" + String(i); | |
currentObject.arrayValue = [Int](count: 100, repeatedValue: 0); | |
if i > 0 { | |
currentObject.referenceValue = testObjects[i-1] | |
} | |
if i > 1 { | |
currentObject.referenceValue = testObjects[i-2] | |
} | |
testObjects.append(currentObject); | |
} | |
label.text = String(testObjects.count); | |
} | |
@IBAction func onTouchClearButton(sender: AnyObject) { | |
testObjects.removeAll(keepCapacity: false) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment