swift手记-3
Posted 麦好
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift手记-3相关的知识,希望对你有一定的参考价值。
//
// ViewController.swift
// learn3
//
// Created by myhaspl on 16/1/23.
// Copyright (c) 2016年 myhaspl. All rights reserved.
//
import Cocoa
class ViewController: NSViewController {
var mystatck:[Int32]=[]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: AnyObject? {
didSet {
// Update the view, if already loaded.
}
}
@IBOutlet weak var inputnum: NSTextField!
@IBOutlet weak var stackstate: NSTextField!
@IBAction func pushNumber(sender: AnyObject) {
mystatck.append(inputnum.intValue)
stackstate.stringValue="堆栈情况"
for mynum in mystatck{
stackstate.stringValue+=String(mynum)+" "
}
}
@IBAction func popNumber(sender: AnyObject) {
let messagebox:NSAlert=NSAlert()
if mystatck.count>0{
let removed = mystatck.removeLast()
stackstate.stringValue="堆栈情况"
for mynum in mystatck{
stackstate.stringValue+=String(mynum)+" "
}
messagebox.messageText="您取出了"+String(removed)
}
else{
messagebox.messageText="堆栈为空"
}
messagebox.alertStyle=NSAlertStyle.InformationalAlertStyle
messagebox.runModal()
}
}
堆栈算法
本博客所有内容是原创,如果转载请注明来源
http://blog.csdn.net/myhaspl/
}
以上是关于swift手记-3的主要内容,如果未能解决你的问题,请参考以下文章