2

When I use == to compare the strings it works on all but some strings that have a space added... (added with [NSString stringWithFormat:@"%@ %@",self.title,collectionName])

But when I compare with isEqualToString, it returns True/YES every time. The comparison in the image goes into the condition and hits the return... Should be impossible for this to hit line 640, but it does.

Can anyone explain this?

alt text

2 Answers 2

2

There is a ";" after the ")" on line 637 that why it always went into the condition... damn I suck... seems like that would throw an error somehow

Sign up to request clarification or add additional context in comments.

1 Comment

Classic C mistake. I once had to debug some code written by a coworker who was actually a really good programmer. He had made the same error three times in the space of 100 source lines. It was probably Friday afternoon code.
1

If you use the LLVM compiler in Debug project setting, (not quite stable enough for release yet I think), you'll get warnings about issues like the one you had.

In your case it would issue a warning than an "if" statement had an empty body.

Used in conjunction with turning on the static analyzer for every build, you can catch a ton of problems early, especially the stupid ones that are hard to debug because they are so stupid they are easy to overlook (and here I am not criticizing you, as I have made the same mistake countless times!)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.