views:

26

answers:

1

I'd like Xcode to warn me if I define a method but don't declare it in the class's @interface block. Is this possible?

Thanks.

A: 

Useful request, but I don't believe there's a way with the current version of gcc. I would open a radar (bugreporter.apple.com) if no one else has a solution. Note that what is needed is slightly more complicated than how you asked it. What you generally really want is a warning if a method implementation does not match any applicable prototype. That would include your @interface of course, but also your formal protocols, superclass @interfaces, and applicable categories (including all superclass categories, particularly NSObject). Even so, the warning would be useful in many cases, especially when you misspell the signature for an informal protocol such as for NSWindow.

For reference, the documentation most useful for this is the ObjC/ObjC++ option page for gcc. Xcode doesn't generate warnings itself.

Rob Napier