Recommendations for Swift Tutorial?

4 views
Skip to first unread message

Chris Larsen

unread,
Feb 17, 2019, 9:25:27 PM2/17/19
to CocoaHeads - Silicon Valley
I've made several attempts to learn Swift. The main sticking point is
that when I buy a book to learn Swift the book is out of date when I
actually get around to actually learning Swift. I think the book I'm
trying to use at the moment was published in 2015 so it's hopelessly out
of date.

Do any of you have a recommendation for a tutorial on learning the
current version of Swift?

The "About Xcode" window says I'm using "Version 10.1 (10B61)". I'm not
sure what version of Swift that translates into but I updated my version
of Xcode in the last week or 10 days so it's pretty current.

Thanks,

Chris Larsen

Jerry Krinock

unread,
Feb 18, 2019, 12:41:57 AM2/18/19
to cocoaheads---...@googlegroups.com

> On 2019 Feb 17, at 18:25, Chris Larsen <lars...@gmail.com> wrote:
>
> I've made several attempts to learn Swift. The main sticking point is that when I buy a book to learn Swift the book is out of date when I actually get around to actually learning Swift. I think the book I'm trying to use at the moment was published in 2015 so it's hopelessly out of date.

Indeed, you should not buy a book to learn Swift.

> Do any of you have a recommendation for a tutorial on learning the current version of Swift?

Start reading “The Swift Programming Language” by author Apple Computer. It is a free download from the “Book Store” in the “Books” app on your Mac. There are editions for all Swift versions, maybe even one for Swift 5 which is in beta. It’s more of a textbook than a tutorial, but Chris since you are a math guy I think this would suit you perfectly.

> The "About Xcode" window says I'm using "Version 10.1 (10B61)". I'm not sure what version of Swift that translates into but I updated my version of Xcode in the last week or 10 days so it's pretty current.

A new Swift project created in Xcode 10.1 will default to Swift 4.2.

David Phillip Oster

unread,
Feb 18, 2019, 5:29:13 PM2/18/19
to CocoaHeads - Silicon Valley
We can talk about this in Thursday's meeting

On Sunday, February 17, 2019 at 9:41:57 PM UTC-8, Jerry Krinock wrote:

> On 2019 Feb 17, at 18:25, Chris Larsen <lars...@gmail.com> wrote:
>
> I've made several attempts to learn Swift. The main sticking point is that when I buy a book to learn Swift the book is out of date when I actually get around to actually learning Swift. I think the book I'm trying to use at the moment was published in 2015 so it's hopelessly out of date.

Indeed, you should not buy a book to learn Swift.

I agree.
 

> Do any of you have a recommendation for a tutorial on learning the current version of Swift?

Start reading “The Swift Programming Language” by author Apple Computer.  It is a free download from the “Book Store” in the “Books” app on your Mac.  There are editions for all Swift versions, maybe even one for Swift 5 which is in beta.  It’s more of a textbook than a tutorial, but Chris since you are a math guy I think this would suit you perfectly.

> The "About Xcode" window says I'm using "Version 10.1 (10B61)". I'm not sure what version of Swift that translates into but I updated my version of Xcode in the last week or 10 days so it's pretty current.

A new Swift project created in Xcode 10.1 will default to Swift 4.2.

I had been looking at https://developer.telerik.com/featured/creating-task-application-ios-using-swift/ which is a tutorial for  creating a simple master-detail interface for iOS using Swift, but it was last updated for Swift 2.  I thought it would be fun to update it to Swift 4.2  The result is in https://github.com/DavidPhillipOster/TasksForSwiftWithPersistingData

It turns out that the article's github repository adds a Core Data persistence layer. That github repository was forked more than a dozen times, but none of the forkers bothered to update it for modern Swift. (Forkers!)

If you look at the commit history, you can see the minimal changes to get the tutorial to run under Swift 4.2. Most of the work was just letting Xcode fix each syntax error. In fact, on Thursday we can do a live demo by forking the original repo from 2015, and walking through the steps as a team.

The U.I. is substantially untouched between old and new swift. In fact, most of it is just Apple's starter app for a master-detail interface.

The Core Data part was crap, so I just re-wrote it, even though I barely know Core Data.

And, I can ask your help with one of the bad spots in my conversion: Surely there is a more idiomatic way to flip an NSNumber holding a BOOL that is a field of an NSObject, in array than:

    if taskMgr.tasks[indexPath.row].isDone?.boolValue ?? false {

      taskMgr.tasks[indexPath.row].isDone = nil

    } else {

      taskMgr.tasks[indexPath.row].isDone = true

    }



Deirdre Saoirse Moen

unread,
Feb 19, 2019, 11:05:16 AM2/19/19
to CocoaHeads - Silicon Valley
Hey David,

Booleans are a PITA in CoreData, alas.

NSNumber.numberWithBool(false) is your friend.

import UIKit
import CoreData

@objc(Task)
class Task: NSManagedObject {
@NSManaged var desc: String?
@NSManaged var name: String?
@NSManaged var isDone: NSNumber?
}

task.isDone = NSNumber.numberWithBool(false)

Etc.

? at the end because those fields can be null.

So your snippet simplifies to:

let isDone = taskMgr.tasks[indexPath.row].isDone ?? false

taskMgr.tasks[indexPath.row].isDone! = (!isDone.boolValue) as NSNumber

Deirdre

Deirdre Saoirse Moen

unread,
Feb 19, 2019, 11:05:16 AM2/19/19
to CocoaHeads - Silicon Valley
The biggest places for getting Swift Tutorials:

1. Paul Hudson's site (hackingwithswift.com) or his YouTube channel: https://www.youtube.com/channel/UCmJi5RdDLgzvkl3Ly0DRMlQ

2. Ray Wenderlich's site: https://www.raywenderlich.com

3. Various Udemy courses (currently $12), especially:

a) Angela Yu's: https://www.udemy.com/ios-12-developer-course/
b) Ray Wenderlich's: https://www.udemy.com/ios-12-and-swift-4-for-beginners-200-hands-on-tutorials/
c) Devslopes: https://www.udemy.com/devslopes-ios12/

I can recommend Stephen de Stephano's other courses, which are built around the corresponding Hacking with Swift book, but I don't really like the outline of the iOS 12 one.

Deirdre

Keith Ray

unread,
Feb 19, 2019, 11:05:17 AM2/19/19
to cocoaheads---...@googlegroups.com
Apple's "Swift Programming Language" is free and covers Swift 4.2, which is the latest "release" version of Swift. (I think 5.0 is still in beta.) 

“This book describes Swift 4.2, the default version of Swift that’s included in Xcode 10.0. You can use Xcode 10.0 to build targets that are written in either Swift 4 or Swift 3.”
The Swift Programming Language (Swift 4.2) Apple Inc.

Follow Swift Evolution to keep track of the latest changes: https://github.com/apple/swift-evolution 

My book is unfinished, but tries to solve the issue of all the out-of-date Swift advice on the internet: https://leanpub.com/wepntk 

I have lost interest in the book, but if people gave me feedback on it, I might try finishing it and keeping it up-to-date.

--
C. Keith Ray

--
You received this message because you are subscribed to the Google Groups "CocoaHeads - Silicon Valley" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocoaheads---silico...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

han zhao

unread,
Feb 19, 2019, 11:05:17 AM2/19/19
to cocoaheads---...@googlegroups.com
Hi, Chris,

I recently finished “Swift in Depth” which covers Swift 4.2 with great introduction to all major feature of Swift. It’s really good - kind of “Effective Swift”.

Best Regards,
Zhao Han

发自我的 iPhone

David Phillip Oster

unread,
Feb 19, 2019, 11:07:18 AM2/19/19
to cocoaheads---...@googlegroups.com
Thank you! That's perfect.

David Phillip Oster

unread,
Feb 19, 2019, 11:09:31 AM2/19/19
to cocoaheads---...@googlegroups.com
I used:

let isDone = taskMgr.tasks[indexPath.row].isDone?.boolValue ?? false
taskMgr.tasks[indexPath.row].isDone = NSNumber(booleanLiteral: !isDone)

Ted Oliverio

unread,
Feb 19, 2019, 7:41:29 PM2/19/19
to cocoaheads---...@googlegroups.com
I will check out the resources listed -- thanks all!

I just wanted to chime in that, for me, personally, the biggest sticking point is that every tutorial I've seen gets bogged down in explaining to me what a variable is, what a for loop is, why if statements are important, etc. and I have a lot of trouble staying awake for that stuff.  Then I start skimming and, somewhere around lesson 3 or 4 I realize that I skipped something important, but am now far too annoyed to go back and look for it.

(Yes, this is a personal shortcoming; I already owned that :)

Anyway, I'm hoping to stumble upon (or be guided to) some sort of "Swift for people who already know how to program", ideally "...for people who already know iOS" (so we can skip the whole "what is { UIViewController, NSObject, etc. }" part, too) lesson-y thing.

Another friend suggested I just pick a small project and implement it, learning as I go.  That might work, too.  I'll get around to that, eventually, "in my spare time".   ;)


Thanks!

Ted Oliverio,

"Love many things, for therein lies the true strength, and whosoever loves much performs much, and can accomplish much, and what is done in love is done well." ~Vincent Van Gogh

"Better than 1000 days of diligent study is one day with a great teacher" ~Japanese proverb





David Phillip Oster

unread,
Feb 19, 2019, 7:52:05 PM2/19/19
to cocoaheads---...@googlegroups.com
Thanks for teaching me about @NSManaged

On Tue, Feb 19, 2019 at 8:05 AM Deirdre Saoirse Moen <dsm...@gmail.com> wrote:
>
Reply all
Reply to author
Forward
0 new messages