Swift作為蘋果推出的新一代程式語言,提供了更加高階的方式來幫助iOS開發者更快更簡單的編寫基於iOS應用,那麼它究竟有什麼好處呢,我們看看下面的程式碼比對。
Swift使用更簡單的語法,如下:
Objective-C
if (myDelegate != nil) { if ([myDelegate respondsToSelector: @selector(scrollViewDidScroll:)]) { [myDelegate scrollViewDidScroll:myScrollView]; } }Swift
myDelegate?.scrollViewDidScroll?(myScrollView)
變數賦值幾乎和Javascript一樣簡單,除了不需要分號。相對於Objective-c,簡化了不少,如下:
Objective-C
NSString *myString = @"This is my string.";Swift
var myString = "This is my string."是不是很讓人興奮?? 下面是你肯定需要的Swift開發資源,相信大家一定會喜歡,記得要加到你常用的書籤裡!
介紹
- A Swift Tour by Apple. Download from iBook Swift programming language or PDF.
- An Absolute beginners guide to Swift by TeamTreeHouse
- A programmers view of apples new Swift language by Richard Byrne Reilly
- Swift is great but you should still know Objective-C first by Jon Friskics
- Swift - Learn Apple's New Programming Language by Examples by Udemy
- Developing iOS8 apps using Swift - Create a Todo application by Shiva Narrthine
來自Fábio Rocha的超簡單教程:
教程系列 #2
一個更深入一些的教程。集中介紹iOS應用開發。可以學習基礎的概念及其高階技巧。處理JSON,Table檢視,非同步圖片載入等等
- Hello World
- Making a web API request and parsing the JSON
- Some best practices using Protocols and Delegates
- Adding an interactive Table View
- Async image loading and caching
- Developing iOS 8 Apps Using Swift Part 6 – Interaction with multiple views
這個教程通過介紹開發一個地理提醒應用來幫助大家瞭解如何使用swift
教程系列 #4
We Heart Swift 是一個新的Swift開發網站,提供很多不錯的內容
- How to make a simple table view with iOS8 and Swift
- Swift Classes - Part 1
- Swift Classes - Part 2
- Swift Around - Simple tableview with a custom cell type
- Make awesome UI components iOS8 using Swift XCode 6
這裡有很多實用的程式碼,你可以下載自己練習使用。
- FlappySwift - Code
- SwiftExample - Table views and web views demostrations
- Swift RSS - An RSS reader app written in Swift. About 100 lines of code and written within about an hour. Proved Swift is a good programming language :-)
- Minimalistic Swift HTTP request agent for iOS and OS X
- HackerNews Reader iOS App
- Swift - Game of Life - Conway's game of life written in Swift with SpriteKit
- SwiftNote - Simple note taking app with today widget and iCloud syncing.
- UIImageView - BetterFace Swift - A UIImageView extension to let the picture-cutting with faces showing better
- UICatalog: Creating and Customizing UIKit Controls in Swift - iOS Developer Library
- Adventure: Building a SpriteKit Game Using Swift - iOS Developer Library
- GestureRecognizers: Using standard UIGestureRecognizers - iOS Developer Library
- Lister: A Productivity App Built in Swift - iOS Developer Library
- Swift Cheat Sheet and Quick Reference
- Swift Cheat Sheet by kpkp
- String Reference Guide for Swift
- Array Reference Guide for Swift
- Swift Cheat Sheet by Grant
- Swift Cheat Sheet
- Google+ Swift Community
- Github Swift Trending Repositories
- Stackoverflow Swift Language
- Reddit iOS Swift
相關閱讀
評論(2)