Jasper Blues Jasper Blues - 1 year ago 71
Objective-C Question

Typhoon inject xib loaded table cells

I’m trying to migrate some of my view controllers and

subclasses over to using Typhoon, but I can’t find any documentation around what to do with cells that are generated from a tableView’s

The TableViewController I’m working with uses multiple cell types which it registers with the TableView in

What should we do to have Typhoon inject cells loaded from xibs?

Answer Source

Probably the easiest thing to do would be to create a view assembly for your xib loaded table cells, and make this one of your application assemblies. Assuming you're using plist integration then you'd add it to your app's plist as:


Logically it would sit to the side of your top-level application assembly.

@interface ViewProvider : TyphoonAssembly

//Reference any other assemblies that you need
@property(nonatomic, strong, readonly) CoreComponents *coreComponents;

//Create a definition for the table cell with the injections that need to happen. 
- (UITableViewCell*)myTableViewCell;

Next inject this into your view controller.

@interface MyViewController : UIViewController

@property (nonatomic, strong) InjectedClass(ViewAssembly) viewProvider;


@implementation MyViewController

- (UITableViewCell *)tableView:(UITableView *)tableView 
    cellForRowAtIndexPath:(NSIndexPath *)indexPath

    //Load the cell from the XIB first. 
    //And now tell Typhoon to inject it
    [self.viewProvider inject:cell];
    //The above matches by type, you can also provide an @selector() 
    //definition in the assembly

    //Any other config to the cell
    return cell;


The documentation for this feature is here.