views:

48

answers:

1

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.

+2  A: 

The answer here is non-obvious, but the compiler is correct. The type SEL is actually just a typedef'd char*, 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 SEL type.

chpwn
That makes sense. I'm new to Objective-C, so things like this keep tripping me up. Why, though, will it compile fine when I build for the device?
MikeQ
Not sure: maybe a compiler bug or something.
chpwn