Search Results

Search found 2 results on 1 pages for 'tomen'.

Page 1/1 | 1 

  • Does NSClassFromString affect performance?

    - by Tomen
    I want to create a controller that depends on the class of a given instance of a model -(BaseController *)getControllerForModel:(Model *)model { BaseController *controller = nil; Class controllerClass = [BaseController class]; //the default value //find the right controller if ([model isMemberOfClass:[ModelClass1 class]]) controllerClass = [ConcreteController1 class]; else if ([model isMemberOfClass:[ModelClass2 class]]) controllerClass = [ConcreteController2 class]; else if ([model isMemberOfClass:[ModelClass3 class]]) controllerClass = [ConcreteController3 class]; ... else if ([model isMemberOfClass:[ModelClassX class]]) controllerClass = [ConcreteControllerX class]; else Trace(TRACELEVEL_WARNING, @"Unrecognized model type: %@", NSStringFromClass([model class])); //Now instantiate it with the model controller = [[[controllerClass alloc] initWithModel:model] autorelease]; return slotController; } I want to find a more flexible solution to this and thought of having a dictionary, which maps Model-Classes to Controller-Classes and then NSClassFromString could give me the right instance. My question is this: Is NSClassFromString using much of my applications performance if i use it several times (say, 100 times at once)? Or would it be about as fast as the above approach?

    Read the article

  • How to set the width of a cell in a UITableView in grouped style

    - by Tomen
    I have been working on this for about 2 days, so i thought i share my learnings with you. The question is: Is it possible to make the width of a cell in a grouped UITableView smaller? The answer is: No. But there are two ways you can get around this problem. Solution #1: A thinner table It is possible to change the frame of the tableView, so that the table will be smaller. This will result in UITableView rendering the cell inside with the reduced width. A solution for this can look like this: -(void)viewWillAppear:(BOOL)animated { CGFloat tableBorderLeft = 20; CGFloat tableBorderRight = 20; CGRect tableRect = self.view.frame; tableRect.origin.x += tableBorderLeft; // make the table begin a few pixels right from its origin tableRect.size.width -= tableBorderLeft + tableBorderRight // reduce the width of the table tableView.frame = tableRect; } Solution #2: Having cells rendered by images This solution is described here: http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html I hope this information is helpful to you. It took me about 2 days to try a lot of possibilities. This is what was left.

    Read the article

1