- Create a new Xcode project.
- Adding basic storyboard elements and constraints.
- Adding and editing view controllers on the storyboard.
- Adding files (such as images) to a project.
- Assigning Swift classes to view controllers.
- Adding outlets between storyboard elements and Swift classes.
- Basic Swift code to change a label's text.
- Adding CocoaPods to your project (Using other developers' code).
How to install CocoaPods:
sudo gem install cocoapods
How to init CocoaPods in your project:
cd [PATH_TO_YOUR_PROJECT]
pod init
How should your Podfile look like for the HelloWorld project:
platform :ios, "8.0"
use_frameworks!
target 'HelloWorld' do
pod 'SwiftyJSON', '~> 2.2.1'
pod 'Alamofire', '~> 1.3'
pod 'BrightFutures'
end
target 'HelloWorldTests' do
end
How to install your Pods after adding them to your Podfile
pod install
Code to show trending topics:
let url = "[TRENDS_URL (see below)]"
request(.GET, url).responseJSON { (_, _, object, _) -> Void in
Queue.main.async {
if let obj:AnyObject = object {
let json = JSON(obj)
self.contentLabel.text = "\n".join(json["trends"].arrayValue.map{$0["name"].stringValue})
}else {
self.contentLabel.text = "ERROR"
}
}
}
Montréal Trends:
http://api.whatthetrend.com/api/v2/trends.json?woeid=3534
World Trends:
http://api.whatthetrend.com/api/v2/trends.json