类方法的使用

来源:互联网 发布:淘宝网店经营技巧 编辑:程序博客网 时间:2024/06/11 18:15

0本文主要介绍swift中类方法的简单的使用,并提供免费下载地址

http://download.csdn.net/detail/wtt561111/9171111

1首先新建swift文件myFunc

////  myFunc.swift//  classFunc////  Created by wangtuntun on 15/10/10.//  Copyright (c) 2015年 wangtuntun. All rights reserved.//import Foundationclass myFunc : NSObject {    class func returnHello() ->String{        return "hello";    }}

2修改viewController文件

////  ViewController.swift//  classFunc////  Created by wangtuntun on 15/10/10.//  Copyright (c) 2015年 wangtuntun. All rights reserved.//import UIKitclass ViewController: UIViewController {    override func viewDidLoad() {        super.viewDidLoad()        // Do any additional setup after loading the view, typically from a nib.        var strGet=myFunc.returnHello();        println(strGet);            }    override func didReceiveMemoryWarning() {        super.didReceiveMemoryWarning()        // Dispose of any resources that can be recreated.    }}




0 0