开发者

How to programmatically setObjectClass for NSArrayController

开发者 https://www.devze.com 2022-12-19 12:23 出处:网络
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 s

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].

0

精彩评论

暂无评论...
验证码 换一张
取 消