Developer

Provisioning Configuration-Based Tiles with Custom Data

You can provision the data for the metadata-driven tile.

To do this, you can either:
  • Assign a custom data source adapter delegate for the tile, or,
  • Pass the context to the tile upon creation. Make sure that the context holds the correct content, that is, custom data structures must be converted to MAFGenericBO objects.

The code below defines a custom data object of the TimeSheetEntry type, and feeds the metadata-driven tile with this model. First, the data is converted from TimeSheetEntry to a TimeSheetEntryBO class that implements the MAFGenericBO protocol so that the Extensibility Framework can digest it.

The TimeSheetEntryBO must map the attributes to the ones defined in MAFGenericBO. For an example, look at the CustomAppUsingMAF demo app’s source.

After the conversion, build the context:
// Create context from BOs
// tseBO is an instance of TimeSheetEntryBO, which implements MAFGenericBO protocol
NSMutableArray* items = [NSMutableArray arrayWithObject:tseBO]; // in this special case we have only one BO to bind
MAFContext* context = [[MAFContext alloc] init];
[context setBOs:items ForBindingID:@"TimeSheetEntryRef"]; 
                
 // Create the tile via MAF Extensibility
 MAFTile* subTile = [[MAFUIManager sharedInstance] tileByIdentifier:@"DetailTileNewWithCustomData" withContext:context];
 subTile.view.frame = CGRectMake(30, 80, 320, 360);
[self.view addSubview:subTile.view];            
[context release];

A different initializer is used here, MAFUIManager + tileByIdentifier: withContext:, which passes the context for the tile to be created. The framework finishes the rest of the tile creation process.