Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLewis Mansbridge
1,119 PointsHi there, i have copied the exact video, but still says its not correct, any ideas ? Thank you
Not working but does on my mac in front of me :(
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append("Debug App", "Fix Bugs")
2 Answers
Greg Kaleka
39,021 PointsHi Lewis,
I haven't watched the video, but that can't be a copy of the code there. The append
method only takes a single parameter, so your code would cause an error. Instead, you have to call the method twice, once per string you want to add to the array:
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append("Debug App")
todo.append("Fix Bugs")
Alternatively, you can add arrays together (called concatenation, as with strings), rather than appending individual items:
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo += ["Debug App", "Fix Bugs"]
Both of these work - up to you which one you choose!
Happy coding!
-Greg
Lewis Mansbridge
1,119 PointsOh i thought i was on the most recent one Haha thank you very much!!!
Greg Kaleka
39,021 PointsNo worries - if you're committed to learning iOS programming, I suggest following the iOS development with Swift 2.0 track.
Lewis Mansbridge
1,119 PointsLewis Mansbridge
1,119 PointsThat worked thank you so much!!!!!
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsLewis, one other point: you should really be taking the Swift 2.0 Basics course, rather than this Swift Basics course. Quite a bit has changed, and you should be learning the latest syntax and rules.
https://teamtreehouse.com/library/swift-20-basics