0

My use case is that I'm trying to start a thread where the destination target object is a class instance. The compiler is giving me an error (Unexpected interface name '': expected expression) when I try to do something like the following:

[NSThread detachNewThreadSelector:@selector(thing:) toTarget:AClass withObject:nil];

@implementation AClass
+(void)thing:(id)arg {
// etc....
}
@end

How do I setup this scenario? Or rather, how do I get the id of the class instance?

Thanks!

Brett
  • 4,066
  • 8
  • 36
  • 50

1 Answers1

1

You can use [AClass class]. Every class responds to the +class method and returns itself.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • But doesn't that return an instance of Class? Is Class a superclass of the object (thus castable to id)? – Brett Aug 24 '12 at 05:32
  • @Brett: No. `Class` is just a typedef for the obj-c runtime type that represents a class. It is not actually the name of a class. – Lily Ballard Aug 24 '12 at 05:33
  • @Brett: Basically, `Class` is just like `id` except it represents any obj-c class instead of any objc- instance. – Lily Ballard Aug 24 '12 at 05:33