Time of Update: 2015-07-15
標籤:學習來自《極客學院:Swift中的字典》工具:Xcode6.4 直接上基礎的範例程式碼,多敲多體會就會有收穫:百看不如一敲,一敲就會 1 import Foundation 2 3 //字典的聲明 4 var dic1: Dictionary <String,String> 5 var scores: [String:Int] 6 //然後是建立字典 7 dic1 = Dictionary<String,String>() 8 scores
Time of Update: 2015-07-14
標籤:ios
Time of Update: 2015-07-15
標籤:swift hello world 直接上代碼: // 輸出函數 println( "Hello world" ) // let 定義常量 var 定義變數 let loginCount = 5 var currentLoginCount = 0// loginCount = 10 // 爆紅// currentLoginCount
Time of Update: 2015-07-14
標籤:學習來自《極客學院:Swift中的字串和集合》工具:Xcode6.4 直接上基礎的範例程式碼,多敲多體會就會有收穫:百看不如一敲,一敲就會 1 import Foundation 2 3 4 /*******************字元********************/ 5 /* 6 1.單個字元來指定字元常量,如“A”、“9” 7
Time of Update: 2015-07-14
標籤://// ViewController2.swift// swift_helloword//// Created by Charlie on 15/7/13.// Copyright (c) 2015年 Json. All rights reserved.//import Foundationimport UIKitclass RootViewController:
Time of Update: 2015-07-14
標籤:學習來自《小波說雨燕 第二季 網路編程(入門篇)》工具:xcode6.4 首先在Main.storyborad中添加並設定好三個label做簡單的介面顯示: 1 import UIKit 2 3 //1、construct a constructs 4 struct Weather { 5 var city: String? 6 var weather: String? 7 var temp: String? 8
Time of Update: 2015-07-13
標籤:ios swift首先我們來建立一個類吧,然後在裡面聲明屬性與方法 class BaseUser { var userName:String = "swh" var password:String = "123" //
Time of Update: 2015-07-11
標籤:swift 拼圖 小遊戲 根據這位朋友的拼圖小遊戲改編 http://tangchaolizi.blog.51cto.com/3126463/1571616 改編主要地方是: 原本著我仁兄的代碼時支援拖動小圖塊來移動的,我參照之前自己java當初寫的,其實不需要拖動,因為只有一個空出來地方,那麼通過點擊事件,接受到點擊事件的小圖只能向一個方向移動或者不能移動。
Time of Update: 2015-07-10
標籤:ios swift uilabel 動態設定高度 import UIKitclass ViewController3: UIViewController { override func viewDidLoad()
Time of Update: 2015-07-10
標籤:switch enum string swift extension import Foundation//MARK:-------枚舉文法-----------//不像 C 和 Objective-C 一樣,Swift 的枚舉成員在被建立時不會被賦予一個預設的整數值enum CompassPoint{ case
Time of Update: 2015-07-09
標籤:swiftSwift 讓所有數值類型都支援了基本的四則運算:加法(+)減法(-)乘法(*)除法(/)1 + 2 // 等於 35 - 3 // 等於 22 * 3 // 等於 610.0 / 2.5 // 等於 4.0與 C 語言和 Objective-C 不同的是,Swift 預設不允許在數值運算中出現溢出情況。但你可以使用 Swift 的溢出運算子來達到你有目的的溢出(如a &+
Time of Update: 2015-07-09
標籤:swift typedef string oc //MARK:-------swift中的typedef--------------//使用 關鍵字定義類型別名,類似typedeftypealias NSInteger = Intvar value : NSInteger = 45value =
Time of Update: 2015-07-09
標籤:c oc swift 橋接 調用 Swift檔案:main.swiftimport Foundation//Swift調用C函數desc1()//Swift調用OC//拿到OC類var funcClass = Root()funcClass.desc2()OC檔案:Root.h#import <Foundation/
Time of Update: 2015-07-08
標籤:swift willset didset 在Swift語言中用了willSet和didSet這兩個特性來監視屬性的除初始化之外的屬性值變化無需說太多,看看下面的代碼你就能很快明白的複製代碼 import Foundationclass People : NSObject { //普通屬性 var firstName:String = “” var lastName:
Time of Update: 2015-07-07
標籤:swift errorSwift Compiler Error Arithmetic operation ‘****** ‘ (on type ‘****‘) results in an overflow 錯誤碼:錯誤原因是數值運算中出現溢出情況.其結果超過了UInt8的0~255的範圍. 和OC不同的是預設不允許在運算中數值溢出.但可以使用溢出運算子來運算
Time of Update: 2015-07-06
標籤:Swift基礎文法學習總結1.基礎 1.1) swift還是使用// 和/* */ 來注釋,並且/* */允許多行注釋. 1.2) swift使用print和println列印,它的傳參是一個泛型,幾乎所有類型都是可列印的. 1.3) swift在語句後面加分號與否都是正確的,但是swift偏好的風格是不在結尾處加分號的.如果有多個語句,必須用分號隔開. 1.4) 在一個數字中庸底線(_)會被忽視,方便認出大數值的的數字,也可以在前面補零. 1.5)
Time of Update: 2015-07-06
標籤:iso oc與swift 混編 swift 語言出來後,可能新的項目直接使用swift來開發,但可能在過程中會遇到一些情況,某些已用OC寫好的類或封裝好的模組,不想再在swift 中再寫一次,哪就使用混編。這個在IOS8中是允許的。先中簡單的入手,先研究在同一個工程目錄下混合使用的情況。為了示範。先準備兩個類第一個是swift語言寫的類,檔案名稱為 act.swift[cpp] view
Time of Update: 2015-07-05
標籤:OC 中調試列印/** * 自訂Log */#ifdef DEBUG#define JYLog(...) NSLog(__VA_ARGS__)#else#define JYLog(...)#endif // swift中我寫了這麼一個類,進行調試輸出 調用方法 Debug.Log(error) import UIKit class Debug:
Time of Update: 2015-06-24
標籤:Swift項目相容Objective-C問題匯總轉載自 http://www.cocoachina.com/swift/20150608/12025.html
Time of Update: 2015-06-24
標籤:import UIKitclass ViewController: UIViewController { @IBOutlet var button : UIButton? //var alertView:UIAlertView? override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,