- 博客(30)
- 资源 (17)
- 收藏
- 关注
转载 我应该直接学 Swift,还是 Objective-C?
我应该先学C/Objective-C还是直接学Swift?Swift是一个全新的语言,与Objective-C或C都没有任何关系。我的意思是它们都是编程语言并且遵守一些基础概念和范例,但是你并不需 要在学习其中一个之前先学另一个。即使你是编程新手,你也可以学习苹果发布的官方的Swift文档而无需先学Objective-C。我正在学习Objective-C,我应该转为学Swi
2015-06-29 20:40:37 733 2
原创 swift switch Double
var v =0.5;switch v{case0...1: println("0...1");default: println("区间外");}
2015-06-22 22:12:28 613
原创 swift 编译预定义 --不知道怎么定义,但是可以#if
var v:Int;#if _COND//不知道怎么定义,但是可以#if v =1;#else v = 2;#endifprintln(v);//2
2015-06-22 22:10:01 924
原创 swift 单例模式
class ca{ var count = 1; static var instance:ca =ca(); class func GetInstance()->ca{ return instance; }}var a = ca.GetInstance();var b = ca.GetInstan
2015-06-22 17:09:53 681
原创 swift oerator[](int i)
class ca{ var v:[Int] = [Int](); subscript(index:Int)->Int{ return v[index]; }}var v =ca();v.v.append(1);v.v.append(2);println(v[1]);
2015-06-21 17:11:19 418
原创 swift 传值 引用 (=、&)
var a =1;var b =a;a=2;println("\(a),\(b)");//2,1struct cs{ var v:Int =99;}var i =cs();var j =i;i.v =98;println("\(i.v),\(j.v)");//98,99class c
2015-06-21 16:25:56 1064 1
原创 swift operator+()
class mypoint{ var x:Int =1; var y:Int =1; init(#x:Int,#y:Int){ self.x = x; self.y = y; } var description:String{//在这里稍有贪心,做一描述成员get变量 get{ ret
2015-06-21 15:55:40 767
原创 swift optional chaining
class ca{ var num:Int =1;}class cb{ var a:ca?;}class cc{ var b:cb?;}var x:cc =cc();var y:Int? =x.b?.a?.num;//或var y = x.b?.a?.num;println("y =\(y),\r\
2015-06-21 11:32:28 706
原创 swift ??
var a:Int?;var b:Int =a ?? 1;//注意空格,相当于c语言 a!=NULL?a:1;println(b);
2015-06-21 10:58:25 511
原创 swift tuple多元组
func swapme(inout a:T,inout b:T,inout c:T){ (a,b,c) = (b,c,a);}var a:Int =1;var b:Int =2;var c:Int =3;println("\(a),\(b),\(c)");swapme(&a, &b, &c);println("\(a),\(
2015-06-21 10:46:36 870
原创 swift protocol mutating
protocol base{ var number:Int{get}; mutatingfunc changeNum();//如果protocol不写mutating那么struct、enum实现此协议将会报错}struct Derive:base { var number = 1; mutating func change
2015-06-21 10:16:57 407
原创 swift Any AnyObject
class ca{ }class cb:ca{ }var library:[Any] = [ca(),cb(),1,]for itemin library{ if let intitem = itemas? Int{ println(item); }}
2015-06-16 22:58:44 472
原创 swift down cast
class ca{ var vaName = "ca";}class cb:ca { var vbName = "cb";}var item:ca =cb();iflet cbitem = itemas? cb{ println(cbitem.vbName);}
2015-06-16 21:13:18 414
原创 swift type identify 类型检查
class ca{ }var library = [ 1, "a", ca()]for itemin library{ if item is ca{ println("\(item) is ca"); } else if itemis Int{
2015-06-16 21:00:42 366
原创 swift override --有一个递归问题未解决
class ca{ var count:Int{ get{ return 1; } set{ self.count = newValue; } } func describe()->String{ return "
2015-06-14 23:22:33 592 2
原创 swift generics 泛型
//泛型函数func repeat(item:ItemType,count:Int)->[ItemType] { var result = [ItemType](); for i in 0.. result.append(item); } return result;}var re = r
2015-06-14 11:30:17 391
原创 swift extension Int
//为了能够在实例方法中修改属性值,可以在方法定义前添加关键字 mutating//试验error,有疑问extension Int{ var description:String{ return "the number \(self)"; }}println(3.description);
2015-06-14 11:29:42 421
原创 swift willSet didSet
class square { var width:Int{ willSet{ println("width will set old=\(width) new=\(newValue)"); } didSet{ println("width did se
2015-06-14 11:28:53 434
原创 swift enum Int
enum rank:Int{ case r1 = 1 case r2 = 2 case r3 = 3 func description()->String{ //enum转String switch(self){ case r1: return "R1";
2015-06-14 11:27:55 2283
转载 Swift中的required修饰符
http://blog.csdn.net/yongyinmg/article/details/39673345普通子类通常情况下,一说到required修饰符,我们最先想到的应该就是普通类(class)的init()方法了。比如下面这个类:class MyClass { var str:String init(str:String) { self.str =
2015-06-14 11:27:32 406
原创 swift protocol
//: Playground - noun: a place where people can playimport Cocoa@objc protocol SortProtocol:NSObjectProtocol{ func same(value:Int)->Bool; //@optional func beg
2015-06-14 11:26:44 332
原创 swift get,set
//: Playground - noun: a place where people can playimport Cocoastruct point{ var x=0; var y=0; init(x:Int,y:Int){ self.x = x;
2015-06-14 11:26:07 894
原创 swift class
//: Playground - noun: a place where people can playimport Cocoavar str = "Hello, playground"class Person { var age:Int;//类成员变量默认是public var name:String?;//
2015-06-14 11:24:55 407
原创 swift struct
//: Playground - noun: a place where people can playimport Cocoavar str = "Hello, playground"struct point{ var x = 0; var y = 0; init(x:Int,y:Int){
2015-06-14 11:22:45 525
原创 swift enum
//: Playground - noun: a place where people can playimport Cocoavar str = "Hello, playground"enum Direction{ case North case South case East
2015-06-14 11:21:37 436
原创 swift closure
//: Playground - noun: a place where people can play//闭包closure,类似c语言的函数指针或oc的blocks//闭包可以让代码显得非常简洁import Cocoa////////////////////////////函数定义func iscontain(arr:[Int],value:Int,cb:(
2015-06-14 11:20:07 520
原创 swift dataStruct
println("Hello, World!")var v1 = ["name":"zxh","age":30,"score":100];println(v1);for v in v1{ println(v);}v1["work"] = "c++";println(v1);var v2 = [
2015-06-14 11:18:10 395
原创 swift func
//初学者,记事本是最好的记忆工具,因为它不会矫正语法变量拼写错误,然后转移到IDE会提示语法错误,单词错误。从此记忆深刻。//// main.swift// myswift//// Created by zhaoxuhui on 15/4/9.// Copyright (c) 2015年 zhaoxuhui. All rights rese
2015-06-14 10:52:00 584
Macraigor.Systems.Flash.Programmer.v3.0.7 with .Incl.Keygen-EDGE.rar
2010-12-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人