How to create a wrapper for Alamofire and SwiftyJSON? Swift – iOS

This blogpost updated with Swift 3 – Xcode 8 – iOS 10 – Alamofire 4.0

AFWrapper
AFWrapper

I have posted a basic tutorial about Alamofire and SwiftyJSON How to use Alamofire and SwiftyJSON with Swift?
And some day before we have learned about Use of Blocks(Closures) or Completion Handlers with Function in Swift – iOS
Let’s combine both the topics to make a WRAPPER of Alamofire and SwiftyJSON.

Read more

How to use Alamofire and SwiftyJSON with Swift? – Swift 3 – iOS 10 – Xcode 8

Swift JSON
Swift JSON

Alamofire is an HTTP networking library written in Swift.
SwiftyJSON makes it easy to deal with JSON data in Swift.

Read more

How to work with WatchKit in Swift Language – iOS 8 #Tutorial #CounterWithWatch

Apple Watch represents a new chapter in the relationship people have with technology. Now you can deliver innovative new experiences to your customers on their wrist. And by adding WatchKit, you can take your apps even further by extending and enhancing their functionality on Apple Watch.

Lets learn how to work with WatchKit by an Counter Example.

Counter Watch Example
Counter Watch

Create New Project in XCode with Swift Language
New Project
New Project

Add Apple Watch Target in your Application
Add Target
Add Target

Select Apple Watch Target
Add Target Apple Watch
Add Target Apple Watch

Select Options for Target
Target Options
Target Options

Storyborad of watch
By adding target you will find the InterfaceController.swift and Interface.storyboard
Storyboard And Swift Files
Storyboard And Swift Files

Design watch with the controls
Design and reposition the controls with the properties of controls.
Design Controls in Watch
Design Controls in Watch

Now Time to do some code and connect the outlets
Connect Outlets
Connect Outlets

Code:
[code language=”obj-c”]
// InterfaceController.swift
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet weak var lblCounter: WKInterfaceLabel!
var counter:Int = 0
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
// Configure interface objects here.
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
@IBAction func upButtonPressed() {
counter = counter + 1
lblCounter.setText("\(counter)")
}
@IBAction func downButtonPressed() {
counter = counter – 1
lblCounter.setText("\(counter)")
}
}
[/code]
Download project with this stuff AppleWatchCounterDemo.zip
Thanks!
Happy Coding 😀