I’m unable to build a very simple program when building for the iPhone simulator. It compiles fine for the device however!
An example code that the compiler doesn’t like:
@protocol Invokable
- (id) invoke: (id)arg with:(id)data;
@end
@interface Worker : NSThread
{
NSAutoreleasePool* memoryPool;
}
- (void) invoke:(id)target selector:(SEL<Invokable>)selector arg:(id)arg data:(id)data;
//........
@end
The problem is with the use of ‘SEL’ – the compiler complains “Qualified type is not a valid object” on every use.
I’m running xcode 3.2.1 on Snow Leopard. I’m really confused about this, because I’ve made absolutely no changes to my build configurations.
The answer here is non-obvious, but the compiler is correct. The type
SELis actually just a typedef’dchar*, and not an Objective-C object.Because of that, and the fact that protocols only apply to Objective-C objects, you can’t specify a protocol on a
SELtype.