swift学习

Swift学习

1.deinit

2.objcBool:

包括:true和false

3.属性放在class外面

4.方法都要加()

5.XX as XX强制类型转换

6.跳转

let mainStoryboard = UIStoryboard(name: "你的storyboard名字",bundle: NSBundle.mainBundle())

let vc : UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("你的viewcontroller的storyboard ID")as UIViewController

self.presentViewController(vc,animated: true,completion: nil)

7.返回dismiss

8.button添加点击事件

按钮触摸点击事件响应

//不传递触摸对象(即点击的按钮)

button.addTarget(self,action:Selector("tapped"),forControlEvents:UIControlEvents.TouchUpInside)

functapped(){

println("tapped")

}

//传递触摸对象(即点击的按钮),需要在定义action参数时,方法名称后面带上冒号

button.addTarget(self,action:Selector("tapped:"),forControlEvents:UIControlEvents.TouchUpInside)

functapped(button:UIButton){

println(button.titleForState(.Normal))

}

9.属性的值与枚举比较,枚举需要类型

if(liveSession.state == LFLiveState.pending || liveSession.state == LFLiveState.start){

10.class在swift中不能使用,用swift代替

11.Xib的使用

collectionView.register(UINib(nibName: "CollectionHeaderView",bundle: nil),forSupplementaryViewOfKind: UICollectionElementKindSectionHeader,withReuseIdentifier: kHeaderViewID)

12.Swift中的willSetdidSet

你可能感兴趣的:(swift学习)