在类(class)当中采用subscript的方法直接用下标 class a{ func b(number:Int)->Int{ return number } subscript(number:Int)->Int{ return number } } var f=a() print(f.b(number:2)) //2 print(f[2]) //2…
在进行Swift和C之间的相互调用时,有必要先了解一下两种语言之间的类型转换关系: C 类型 Swift 类型 bool CBool char, signed char CChar unsigned char CUnsignedChar short CShort unsigned short CUnsignedShort int CInt unsigned int CUnsignedInt long CLong unsigned long CUnsignedLong long long…