1

Something like

Class tableViewCellClass = BGUIBusinessCellForDisplay.class;
tableViewCellClass * cell = (tableViewCellClass *)tableView.visibleCells[0];

That gets compile error.

2
  • 3
    What are you trying to accomplish? Commented Jan 21, 2013 at 19:38
  • You're confusing two separate stages of your progam: compilation time and run time. The variable's type only exists during the first stage. The return value of [BGUIBusinessCellForDisplay class], which is an object, doesn't exist until later, at run time. However, there is almost certainly a way to accomplish your goal, so please explain what it is. Commented Jan 21, 2013 at 19:46

2 Answers 2

3

you cannot type it using the class variable - as it's an object, not a type. You can however type it id. e.g.

Class myClassVar = self.class;
id newInstance = [[myClassVar alloc] init];
Sign up to request clarification or add additional context in comments.

Comments

1

Typedefs are as close as you can get:

typedef BGUIBusinessCellForDisplay tableViewCellClass;

Which somewhat allows you to do what you want, but the overall question I have is what are you trying to accomplish?

1 Comment

typedef is at compile time. I tried to have a code that will work with 2 types of UItableViewCells. The codes are similar but I want one subclass to deal with one type and the other with another type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.