Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Collections What is an Array?

Mehran Amini Tehrani
Mehran Amini Tehrani
1,523 Points

Array

Hello,

How can I print out the number of items in the todo array using println? I know for counting I need to write for example: todo. count, but it does not work.

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

4 Answers

Here's a link.

The println function prints the value as a string.

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

println(todo.count)

Remember that the ebook "The Swift Programming Language" by Apple is a great (and free) resource on Swift, and you can learn a lot just by skimming through the first chapter.

Mehran Amini Tehrani
Mehran Amini Tehrani
1,523 Points

Thanks for your response... How can I get that book?

Great!