iOS: First App from Apple

This entry is part 3 of 32 in the series iOS Apps

A video by Apple on how to build an iOS app in Swift language from scratch, in less than ten minutes.

Below is the source code and I am using the latest version of Swift.

import UIKit

class ViewController: UIViewController {

    @IBOutlet var photoImageView: UIImageView!
    
    let context = CIContext(options: nil)
    
    
    @IBAction func appFilter(sender: AnyObject) {
        
        let inputImage = CIImage(image: photoImageView.image!)
        
        let randomColor = [kCIInputAngleKey: (Double(arc4random_uniform(314))/100)]
        
        let filteredImage = inputImage?.imageByApplyingFilter("CIHueAdjust", withInputParameters: randomColor)
        
        let renderedImage = context.createCGImage(filteredImage!, fromRect: filteredImage!.extent)
        
        photoImageView.image = UIImage(CGImage: renderedImage)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

 

iOS: Hello World with a text field

This entry is part 2 of 32 in the series iOS Apps

Hello World created with Swift with a text entering field.

I tested it with my latest version of xCode and this is what I have in ViewController.swift.

import UIKit

class ViewController: UIViewController {

    @IBOutlet var nameLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func helloWorldAction(nameTextField: UITextField) {
        
        nameLabel.text = "Hi \(nameTextField.text!)"
        
    }

}