Teaching app development with Swift

Are you planning to use the new App Development with Swift course and Teacher Guide in your teaching? Use this thread to share feedback and ask questions about these materials. #swiftedu

Replies

I've got my son working throught it. Where do we send feedback - this forum?

Hello,

I am interested in translating the "App Development with Swift" guide to Spanish. How can I get the .iba files (iBooks Author files)?

Thanks a lot,

Claudio

Hola, Estoy interesado en traducir la guía "App Development with Swift" del Inglés al Español. ¿Cómo puedo conseguir la versión editable en iBooks Author ?

Gracias y saludos,

Claudio

Hi I'm working my way trough the "App Development with Swift" book and I'm getting stuck at 07_BoogieBot.

When working trough the exercise the live View doesn't work

(Xcode 7.3.1)


runBoogieBotDemoMode() Use of unresolved identifier 'runBoogieBotDemoMode'

any help?

Without taking a closer look, I think you might need Xcode 8 to use the new playgrounds (without modification)?

Some of the scoping (private, public) has changed in Swift, and I noticed that broke a few things until I upgraded.

I may be mistaken, but there appears to be a bug in the 12_InstancesMethodsProperties.playground, page 16 of 17: "Exercise: Treehouse Pulley".


In the third exercise, it says "Use the TreehousePulley type's addLoadToBasket method to add the items you defined above."

However, when attempting to run the following code:


let item1 = 12
let item2 = 120
let item3 = 1080

let ricketyRope = TreehousePulley(weightCapacity: 200)
let strongRope = TreehousePulley(weightCapacity: 2000)

ricketyRope.addLoadToBasket(item1)


Playground execution failed: error: Exercise-Freight Elevator.xcplaygroundpage:17:13: error: 'addLoadToBasket' is inaccessible due to 'internal' protection level

ricketyRope.addLoadToBasket(item1)


I'm new to Swift, so after a lot of digging around through the Swift Reference Guides, I discovered the documentation for public vs private vs internal access for structures and functions. I then went into Exercise-Freight Elevator > Sources > FrieghtElevator.swift and changed the following code:

mutating func addLoadToBasket(loadWeight: Int) {
        currentWeight += loadWeight
    }

to this:

public mutating func addLoadToBasket(loadWeight: Int) {
        currentWeight += loadWeight
    }


It would get further in the code, but give me a different errror:

Playground execution failed: error: Exercise-Freight Elevator.xcplaygroundpage:17:1: error: cannot use mutating member on immutable value: 'ricketyRope' is a 'let' constant

ricketyRope.addLoadToBasket(item1)


So after changing:

let ricketyRope = TreehousePulley(weightCapacity: 200)

to:

var ricketyRope = TreehousePulley(weightCapacity: 200)


It got further but then:

Playground execution failed: error: Exercise-Freight Elevator.xcplaygroundpage:17:29: error: missing argument label 'loadWeight:' in call

ricketyRope.addLoadToBasket(item1)

So I changed it to:

ricketyRope.addLoadToBasket(loadWeight: item1)


and it finally went through.


Was this intentional? The first error was very confusing and the concepts of private / public / internal access had not yet been introduced in the previous lessons.

The second error was also confusing, because a let constant was already declared for "rickeyRope" but it is required to be a variable to do the addLoadToBasket function?


I am very new to Swift and Xcode, so please correct me if I've gotten something wrong here, or I was supposed to do something else 🙂

Meet that problem and lose over 2 hours. Thank you for research and answer.

> Was this intentional?

Hope not. But i'm from Russia.


Nore than you correct:

method "removeLoad" needs to add "public" too.

And, if i'm not mistake:


    public func canHandleAdditionalLoad(_ load: Int) -> Bool {
        if currentWeight + load > weightCapacity {
            return true
        } else {
            return false
        }
    }


needs to be:

    public func canHandleAdditionalLoad(_ load: Int) -> Bool {
        if currentWeight + load < weightCapacity {
            return true
        } else {
            return false
        }
    }


not ">", it's "<". Is that right?

Method check for ability of carry more weight.

In sourse it answers "true" if "currentWeight + load" more than "weightCapacity"

Thank you drgant and Pashgun for debugging this. I encountered the same problem. As per the exercise in page 16 suggessted, I could not find addLoadToBasket method in the autosuggest either. This seems to be a bug for sure.

I'm working through App development with Swift using xcode 8.2. A problem is that it seems xcode normally writes any changes back to the xcodeproj that was opened. This means that if I make any mistake, the project is messed up and the only solution is to download the teaching materials again. Shouldn't it say something about how to avoid this up front?


On lesson 13 QuestionBot page 93 it invites me to change the emoji. This didn't work for me. The emoji changed in the attributes inspector but not anywhere else. Running the project still showed the old emoji. I then tried clicking on View (under View Controller Scene), then clicking back on the emoji label, and this caused the new emoji to appear there and simultaneously the emoji disappeared from the central edit window, except for three white selection squares. It seemed as if the emoji box had been reduced to zero width. See screenclip http://www.brisk.org.uk/pics/a0.png

But when run the new emoji did show. Once it has got in this state I cannot restore normal appearance of edit window.


(Please ignore my username - I was frustrated eqrlier by something else)

I'm using App Development with Swift in my classroom with the associated XCode files. I notice that when students are on a playground, it auto-saves whatever changes they make. But sometimes they really ***** things up badly and the page is not really salvagable. Is there a quick and easy way to get a student back to the default playground page before they started messing around on it?


For instance, a student accidentally deleted a huge chunk of the original code on a page and didn't realize it until the next day. How would we get that page back to its clean state?

Xcode has never employed much of an 'undo/redo' oops word processor-style mode beyond immediate session, as an example. Not it's job, as they say.


The traditional way to deal with (big to the user) missteps has always been the same...rely on backups (example Time Machine) and/or source control (see Xcode's SC menu and Help). I'd avoid snapshots, BTW...


I'd like to think that particular topic would be one of the basics as part of any coding curriculum 😉

Maybe canHandleAdditionalLoad method has some bug too. You may want to change HandleAdditionalLoad method with < instead of >:

public func canHandleAdditionalLoad(_ load: Int) -> Bool {

if currentWeight + load < weightCapacity {

return true

} else {

return false

}

}

I have another suggestion: just add the "_" sign in the declaration:


public mutating func addLoadToBasket(_ loadWeight: Int) {


So you don't need to know the name of the argument.

Both label have to be set to "---" alignment and Lines: 0


The Response Label was set to 0 - so the other label disappeared.

I am using the latest version of xcode (Version 8.3.3 (8E3004b)) this is the error I am getting in the file 07_BoogieBot.playground

'M_Pi_4' is deprecated: Please use 'Double.pi or.pi/4' to get the value of correct type and avoid casting.

Is there an answer key for the exercises?