swift手记-6

前端之家收集整理的这篇文章主要介绍了swift手记-6前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//
//  ViewController.swift
//  learn
//
//  Created by myhaspl on 16/1/26.
//  Copyright (c) 2016年 myhaspl. All rights reserved.
//

import Cocoa

class ViewController: NSViewController {

    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 hashresult: NSTextField!
    @IBOutlet weak var sourcestr: NSTextField!
    @IBAction func hashbutton(sender: AnyObject) {
        let sourcestring=sourcestr.stringValue
        var hashres:Int64=1
        var str:String
        for charascii in sourcestring.utf8{
            str="\(charascii)"
            hashres = str.toInt()! + 33 * hashres
        }
        hashresult.stringValue=String(hashres)
    }
}

字符串HASH

博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/


猜你在找的Swift相关文章