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 trial

iOS Swift Basics (retired) Collections Modifying an Array

Roderick Royce
Roderick Royce
1,236 Points

Wrong Value on 3rd Array Challenge. todo.insert("Learn iOS", atIndex: 1) How do I have a wrong value here?

The Challenge asks me to append an array item at the 2nd position, (0,1) so I inserted 1 and the value is "Learn iOS" and this is all inserted but the computer says "wrong value." What do I need to fix?

arrays.swift
var todo = ["Learn Swift", "Build App", "Deploy App"]

todo.append("Debug App")
todo.append("Fix Bugs")

let item = todo.removeAtIndex(2)
todo.insert("item", atIndex: 2)
todo.insert("Learn iOS", atIndex: 1)

can you take a screenshot of the error

Roderick Royce
Roderick Royce
1,236 Points

I can copy what I have down:

Finally, we forgot to add that we need to learn iOS development prior to building an app. Insert a new item titled "Learn iOS" at the second position in the todo array.

var todo = ["Learn Swift", "Build App", "Deploy App"]

todo.append("Debug App")

todo.append("Fix Bugs")

let item = todo.removeAtIndex(2)

todo.insert("Learn iOS", atIndex: 2)

! error reads as follows: Bummer! You need to call the 'insert' method on the array. Me: the last line of code I have above is todo.insert and I thought that is the insert method.

Thank you for your help

Roderick Royce
Roderick Royce
1,236 Points

Hello Meek,

 Thank you for seeking my question but I had it right I just needed to change the atIndex change from 2 to 1. I thought I tried this but I did it again today and finished the challenge.

Thanks Meek D!