jcrin / ios Goto Github PK
View Code? Open in Web Editor NEWwork_test
work_test
//
// main.swift
// Swift2_Tuples
//
// Created by Swift on 2015/5/4.
// Copyright (c) 2015年 Swift. All rights reserved.
//
import Foundation
var product = ("iPad Wifi", 16999) //元祖 集合值
var (device, price) = product
println("(device) 售價(price)元");
//var (device,_)=product // 同名 會所屬不同記憶體空間 可能有修改
//println("(device)") // _ 代表不使用
println("(product.0)\t售價(product.1)")
var product2 = (device:"MacBook", price:45333, capacity: 32);
println("(product2.device) (product2.price) (product2.capacity)");
var test = (123,434);
var (a,b) = test; //只有copy 非參考
a = 3;
println("(test)");
//
// main.m
// oc_test
//
// Created by Swift on 2015/5/1.
// Copyright (c) 2015年 Swift. All rights reserved.
//
@interface Myobject: NSObject{ //繼承基礎物件 全部物件都是私有
int m_firstnumber; //全浴變數
int m_secoundnumber;
}
-(int)getFirstNumber;
-(void)setFirstNumber:(int)num;
-(int)getSecoundNumber;
-(void)setSecoundNumber:(int)num;
@EnD //對應interface
@implementation Myobject
-(int)getFirstNumber{ //+ statci - non-static
return m_firstnumber;
}
-(void)setFirstNumber:(int)num{
m_firstnumber = num;
}
-(int)getSecoundNumber{
return m_secoundnumber;
}
-(void)setSecoundNumber:(int)num{
m_secoundnumber = num;
}
int main(int argc, const char * argv[]) {
// @autoreleasepool {
// // insert code here...
NSLog(@"Hello, World!");
// }
printf("Hello world\n");
Myobject *obj =[[Myobject alloc] init]; //所有都是指標 且 都需要初始化
//呼叫方法 [變數 方法]
[obj setFirstNumber:20];
[obj setSecoundNumber:30];
NSLog(@"First %i\n",[obj getFirstNumber]); // string is object
printf("%i\n",[obj getSecoundNumber]);
return 0;
}
//
// main.swift
// oper
//
// Created by Swift on 2015/5/4.
// Copyright (c) 2015年 Swift. All rights reserved.
//
import Foundation
var a:Int = 10, b:Int = 20, c:Float = 12.43, d:Float = 24.3;
println("(a)(b)=(a * b)");
println("(a)(b)=(a / b)");
println("(a)+(c)=(Float(a) + c)"); //不同型態 不能互動
println("(a)*(c)=(Float(a) * c)");
println("(b)%(c)=(b % Int(c))");
println("(b)%(c)=(Float(b) % c)");
var str1:String = "ABC";
var str2:String = "DEF";
var str3 = str1 + str2;
println(str3);
a = b++; // 會先給b原本的值
println("(a)\t(b)");
println("(a)>(b)\t(a > b)");
println("(a)<(b)\t(a < b)");
println("(a)=(b)\t(a == b)");
println("(a)!=(b)\t(a != b)");
println("( !(a > b) )");
//=========================swpa===============
println("(a)\t(b)");
var temp:Int = b;
b = a;
a = temp;
println("(a)\t(b)");
//
// main.swift
// swift_1
//
// Created by Swift on 2015/5/4.
// Copyright (c) 2015年 Swift. All rights reserved.
//
import Foundation
//println("Hello, World!")
var age:Int = 18 //變數 "=" 運算符號 需要空格
// ":" 不用空格
var 身高:Float = 174.8;
var 體重 = 88 //自動依照數值 配type
let name:String = "小明" //常數 不可更動內容
//name = "錯誤"
age = 28;
身高 = 198;
體重 = 94;
print("年紀(age)歲 身高(身高)cm, 體重(體重)Kg\n");
// + 前後加 space 不然運算會出錯
//分號可有可無
println("年紀" + String(age) + "歲,") // 強制轉型 "+"前後空格
// "身高"+string(身高)"cm," // 中文目前還不可進行運算 如強制轉型
let minIntU8:UInt8 = UInt8.min //unsing
let maxIntU8:UInt8 = UInt8.max // UInt32 = Int
println("UInt 的最小值(minIntU8) UInt的最大值(maxIntU8)")
var dValue:Double = 100.999;
var fValue:Float = Float(dValue);
var iValue:Int = Int(fValue);
println("(dValue)\t(fValue)\t(iValue)")
//var number:Int
var number:Int? // ? 未定義內容 有實體空間
print("number = (number)\t");
number = 100;
println("(number)"); //optional 可選的
var boolTrue:Bool = true;
var boolFalse:Bool = false;
assert(boolTrue, "發生錯誤"); // true 繼續執行
// false 程式中斷 顯示後方錯誤訊息
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.