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

2 Answers

Jesus Mendoza
Jesus Mendoza
23,288 Points

Bool returns true or false values and void returns nothing

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

So I would use BOOL in something like an if else statement? And why would I want to return nothing?

Jesus Mendoza
Jesus Mendoza
23,288 Points

BOOL Example: You want to make a function to connect to a database, if you connected successfully then you return true, else you return false.

Void Example: You want to alert something on screen, then you create a void function because you don't want to return anything, you just want to pop up the alert.

Btw are you asking about BOOL and void in functions or in variables?

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

Okay. I'm not really sure, functions and variables, I still don't have the differences down.