Information Technology Reference
In-Depth Information
Xcode has flagged two errors in this line of code—a missing delimiter, and a misspelled class name.
CAUTION
Xcode 4 displays a warning whenever you call a method before it's defined. This is a feature of Objective-C—the
compiler does a single pass and always flags unresolved method references, even if they're resolved later. Unfortu-
nately this makes it difficult to tell the difference between bad code that attempts to call a nonexistent method
and calls to valid methods that are defined lower in the implementation. You can avoid these messages by adding
valid method names to a category declaration at the start of an implementation, but this isn't often done.
Using Fix-It code tips
If you click on an issue flag in the gutter, Xcode may suggest a possible fix, as shown in Figure 15.2. To accept
the fix, double-click the blue fix-it suggestion. The Fix-It feature is good at catching obvious errors, but it isn't a
full expert system and lacks awareness of certain common code idioms. For example it's confused by the
…self = [super init]…
assignment which is often used in class initialization code. It assumes this code is a mistyped conditional and
suggests a fix accordingly.
Experienced developers will find it easy to tell the difference between helpful and misleading fix-it suggestions.
Newcomers should be aware that this feature isn't a substitute for writing good code, and that some of its sug-
Search WWH ::




Custom Search