How to programmatically setObjectClass for NSArrayController
I'm having a problem with what should be a very simple thing. I want to create an NSArr开发者_JAVA百科ayController and specify the class it manages. Problem is, I can't figure out the correct way to specify the Class in the setObjectClass method. I want to do the following:
[projectArrayController setObjectClass:SKHProject];
SKHProject is a class that I've imported in the implementation file. I keep getting the "Expected expression before 'SKHProject'" error, but I can't figure out the correct expression. Where am I going wrong?
Do
[projectArrayController setObjectClass:[SKHProject class]];
!
Just found it
[projectArrayController setObjectClass:[SKHProject class]];
Thanks anyway
You can only use a class name as the receiver of a message; you can't use it in any other context. So, to pass the Class
somewhere, send it a message asking it for itself: [SKHProjectClass class]
.
精彩评论