View on GitHub

BigNerdRanch-SwiftDevelopment

Storage for playground and projects while learning from the Big Nerd Ranch book

Personal findings and notes

This list contains findings and notes I made during the exploration of the book and playing around with Swift.

Please note that there are from a standpoint of a developer with .NET development experience and therefor might use terms related to .NET or use comparisons to .NET.

IDE

General

Exceptions and Exception Handling

Protocols (similar to Interfaces)

Enumerators

Struct

Classes

Functional aspects

Properties and variables

Extensions

Nullability / nil

Garbage collection (See GarbageTown example)

Event handlers

Closures

###Equality, comparison and operators

Application development for Mac/iOS

iOS development

func loadItems() { if let itemsArray = NSArray(contentsOf: fileUrl) as? [String] { items = itemsArray; } }

- Classes used should inherit from NSObject (this is not by default, unlike .NET auto-inheriting from Object)
- When writing delegate classes you might encounter an error telling you that the protocol is not implemented correctly:
```Class does not conform NSObjectProtocol```, this is due to classes not inheriting NSObject by default in swift. A correct inheritance should include the protocol *and* NSObject: ```class TodoTableObserver : NSObject, UITableViewDelegate```
- Also interesting, protocols with _ parameters need to be defined that way.
```swift
func tableView(_ view : UITableView, didSelectRowAt: IndexPath) {} //Will match
func tableView(view : UITableView, didSelectRowAt: IndexPath) {} //Will NOT match (but gives a warning stating that the protocol is almost matched)

Note that the whole signature needs to match, including the return object (which is not always very clear in the top level documentation).

Interop Objective-C and Swift

Book.finish()