The unusual error |
Then I noticed that things seemed "not quite right" in the file. And here's what I mean by "not quite right":
Comparison of the new and old code |
The original code had coloring for the SYNTHESIZE_SINGLETON_FOR_CLASS macro which the new code didn't. Now what the hell did that mean? Why didn't it recognize it as regular code? I tried adding the #import for the SynthesizeSingleton.h - no luck. I tried removing it - no luck. So back to the web! And nothing. And I had a sad face.
Something made me open the right-hand side bar for the file - and that's when I noticed something interesting. There was a check box under the section called "Target Membership". It was unchecked for the new file. But right there was my app logo next to the check box. And when I clicked it? The syntax coloring changed for SYNTHESIZE_SINGLETON_FOR_CLASS! Well, how 'bout them apples?
So what was the lesson learned or, in my case, re-learned? Really check to see what's happening with the error messages you get from Xcode. Sometimes they seem cryptic but actually contain the exact information you need to fix the error. But I think in this particular case it means that sometimes the differences between what you expect and what you get may be slightly hidden from you. I didn't even think about the right-hand properties sidebar for my .m file - and it didn't dawn on me that when I added the file to the project that it wouldn't be appropriately associated. But the next time I add a class, I'm going to be double-checking to make sure that the target membership is set correctly. And maybe this saves you a little time in the end too.
Happy coding.
1. The SynthesizeSingleton macro I'm using is from the incredibly awesome Matt Gallagher of CocoaWithLove.com. The singleton code is located here.