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 Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Signing Up New Users: Part 1 (UIAlertView)

Or Operators Not Working

Currently working through the Self-Destructing messaging app project and having trouble on the signup page setup portion.

The lesson instructed me to create code to prevent anyone from signing up with a user, pass, and email that has spaces in-between the lettering.

I'm using an if statement to prevent this, but for some reason I'm receiving a "parse issue: expected expression" error when running the code. It states the OR operator is causing this.

Here's my code:

if ([username length] == 0) || [password length] == 0 || [email length] == 0 ) { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:@"Make sure you enter a username, password, and email address!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

The error points out the failing point at the first ||.

Not sure why this operator isn't working.

If i remove the or operator and just keep the ([username length] == 0), it works just fine.

Appreciate your time,

Ryan

3 Answers

Hey Chris,

Thank you for the response. Unfortunately i made the mistake of accidentally deleting the 0 when I posted this question. I have the 0 listed in my project and it still fails. I've updated the code in the original posting.

Hope we can continue trying to figure this out.

Chris Shaw
Chris Shaw
26,676 Points

I just noticed something I didn't the first time around, you have the following 0) || [, the parentheses shouldn't be there.

if ([username length] == 0 || [password length] == 0 || [email length] == 0) { /* ... */ }
Chris Shaw
Chris Shaw
26,676 Points

Hi Ryan,

You appear to be missing the operator value for [email length], apart from that your statement should work just fine.

That did the trick! Thanks.