cs193p – Lecture #6 Protocols and Delegation, Gestures

Please note, this blog entry is from a previous course. You might want to check out the current one.

The sixth lecture contains theory interspersed with demos of the just learned topics.

Extensions

Extensions allow to add methods and properties to classes even if the source is not available. It is not possible to override existing methods and properties. New properties can not be used to store data.

Protocols

Protocols define APIs of methods and properties a caller should provide. It has no storage or implementation associated.

protocol SomeProtocol : class, InheritedProtocol1, InheritedProtocol2 {
    var someProperty: Int { get set }
    func aMethod(arg1: Double, anotherArgument: String) -> SomeType 
    mutating func changeIt()
    init(arg: Type)
}

Continue reading “cs193p – Lecture #6 Protocols and Delegation, Gestures”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #5 – Objective-C Compatibility, Property List, Views

Please note, this blog entry is from a previous course. You might want to check out the current one.

Objective-C Compatibility

Lecture #5 starts with theory on how Swift was built to be compatible with Objective-C and thus provides numerous seamless bridging methods:

  • NSString bridges to String
  • NSArray bridges to Array<AnyObject>
  • NSDictionary bridges to Dictionary<NSObject, AnyObject>
  • Int, Float, Double, Bool bridge to NSNumer – but not the other way around – use instead intValue, floatValue, doubleValue and boolValue

Additionally, it is possible to implicitly cast using as.

Continue reading “cs193p – Lecture #5 – Objective-C Compatibility, Property List, Views”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #3 – Applying MVC

Please note, this blog entry is from a previous course. You might want to check out the current one.

Lecture #3 continues the calculator demonstration, adding the model to the MVC pattern. In addition he shows how to use

  • enums,
  • simple initializers,
  • returning optionals,
  • dictionaries,
  • and tuples.

The lecture is available via iTunes named “3. Applying MVC”. The code for the demo is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #2 – More Xcode and Swift, MVC

Please note, this blog entry is from a previous course. You might want to check out the current one.

Lecture #2 continues with the demonstration from the previous lecture showing:

  • how to use arrays,
  • computed properties,
  • the conditional statement switch,
  • functions as types,
  • various combinations of closure syntax defining functions “on the fly”,
  • method overloading – same method name, different arguments,
  • and more Autolayout.

Continue reading “cs193p – Lecture #2 – More Xcode and Swift, MVC”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #1 – Logistics, iOS8 Overview

Please note, this blog entry is from a previous course. You might want to check out the current one.

Like every year lecture #1 is an general introduction of the course with an overview about iOS, MVC and this time the Swift.

… and again Paul Hegarty stresses the importance of being familiar with object oriented programming as prerequisites for the course and that it is not for absolute beginners.
Continue reading “cs193p – Lecture #1 – Logistics, iOS8 Overview”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail