Swift is an innovative new programming language for Cocoa and Cocoa Touch. Writing code is interactive and fun, the syntax is concise yet expressive, and apps run lightning-fast. Swift is ready for your next iOS and OS X project — or for addition into your current app — because Swift code works side-by-side with Objective-C.
Here are some of features:
- Designed for Safety
- Fast and Powerful
- Interactive Playgrounds
- Ready Today
- Read-Eval-Print-Loop (REPL)
Before we start this tutorial, make sure you already setup your machine (mac) with these tools:
- Xcode 6.3.2 GM seed – https://developer.apple.com/xcode/downloads/ (More stable than Xcode 6.3.1).
Open Xcode and create a new Single View Application. For product name, use RevivalxSwiftToDoList and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and make sure only iPhone is selected in Devices.
Install CocoaPods using terminal. What is CocoaPods?
CocoaPods manages library dependencies for your Xcode projects.
The dependencies for your projects are specified in a single text file called a Podfile. CocoaPods will resolve dependencies between libraries, fetch the resulting source code, then link it together in an Xcode workspace to build your project.
Ultimately the goal is to improve discoverability of, and engagement in, third party open-source libraries by creating a more centralised ecosystem.
Open your terminal and type this command.
sudo gem install cocoapods
Go to your directory and initialize your pod using this command.
cd /Users/MNurdin/Documents/iOS/RevivalxSwiftToDoList pod init
Open your finder and edit pod file (Podfile) with these one.
# Uncomment this line to define a global platform for your project #platform :ios, '8.0' use_frameworks! pod 'HanekeSwift' pod 'Parse' pod 'ParseFacebookUtils' pod 'ParseUI' target 'RevivalxSwiftToDoList' do end target 'RevivalxSwiftToDoListTests' do end
The reasons why we need these libraries because
- Haneke – Haneke resizes images and caches the result on memory and disk. (https://github.com/Haneke/HanekeSwift)
- Parse -Instantly add a powerful cloud database. No server, no back end. (https://parse.com/)
Go back to your terminal and run pod install to install all the dependencies. It takes a few of minutes to download.
After finish downloading, open RevivalxSwiftToDoList.xcworkspace file, not RevivalxSwiftToDoList.xcodeproj because we want to use the pod.
Storyboards and interface builder
Set to Compact Width | Any Height.
Delete ViewController.swift and ViewController on the Main.Storyboard. Drag a Table View Controller and View Controller to Main.Storyboard.
Select Table View Controller and navigate to Attributes inspector. Tick Is Initial View Controller.
Select the Table View Controller again and in the menu go to Editor > Embed In > Navigation Controller. This adds a Navigation Controller to the storyboard with an initial scene.
Select the Navigation Item under the Table View Controller, and in the Attributes Inspector type To Do List as the Title.
From the Object Library, drag a Bar Button Item to the right of the navigation bar on the Table View Controller. Select the Bar Button Item (which has a default value of “Item”) and in the Attributes Inspector, in the Identifier option, choose Add. This will change the button to the add symbol (+).
Select the Table View Controller, press control button and drag to View Controller like image below. We added a segue.
Name it MySegue in Show the Attributes Inspector > Identifier.
Continue on next post, http://blog.revivalx.com/2015/08/12/develop-a-simple-ios-mobile-app-todolist-using-swift-part-2/.