Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes some methods for working with a dashboard composite block. After starting the example the following operations are executed:
Dashboard composite block is retrieved.
Title of obtained composite block is retrieved.
Embedded controller coordinates of the obtained composite block are retrieved.
Index of the obtained dashboard composite block is retrieved.
It is retrieved whether to show the composite block in the slide mode.
Loading indicator of the obtained composite block is displayed and hidden.
Executing the example requires that the repository report contains more than one block. Then it is required to add the following methods with their implementation in the ViewController class (see the Displaying of Dashboard section):
// Executes operations related with view controller calculation start -(void)calculationsStart{ // Get dashboard controller MADashboardReportViewController* dashboard = (MADashboardReportViewController *)m_controller; // Get dashboard APKap *report = [dashboard report]; // Get composite block array NSMutableDictionary *blocks = [report compositeBlocks]; if ([blocks count] > 0) { // Get composite block key NSString *key = [[blocks allKeys] objectAtIndex:0]; // Get composite block by specified key APCompositeBlock *block = [blocks valueForKey: key]; // Show loading indicator [block dataViewControllerWillStartCalculations]; } else { NSLog(@"No composite blocks"); } // Call the calculationsStop method after the 5 second pause [self performSelector:@selector(calculationsStop) withObject:nil afterDelay:5.0f]; } // Executes the operations related with view controller calculation end -(void)calculationsStop{ // Get dashboard controller MADashboardReportViewController* dashboard = (MADashboardReportViewController *)m_controller; // Get dashboard APKap *report = [dashboard report]; // Get composite block array NSMutableDictionary *blocks = [report compositeBlocks]; if ([blocks count] > 0) { // Get composite block key NSString *key = [[blocks allKeys] objectAtIndex:0]; // Get composite block by specified key APCompositeBlock *block = [blocks valueForKey: key]; // Hide loading indicator [block dataViewControllerDidFinishCalculations]; } else { NSLog(@"No composite blocks"); } }
It is also required to add the following code in the body of the executeExample method of the ViewController class:
// Get dashboard controller MADashboardReportViewController* dashboard = (MADashboardReportViewController *)m_controller; // Get dashboard APKap *report = [dashboard report]; // Get composite block array NSMutableDictionary *blocks = [report compositeBlocks]; // Get composite block key NSString *key = [[blocks allKeys] objectAtIndex:0]; // Get composite block by specified key APCompositeBlock *block = [blocks valueForKey: key]; // Get composite block title NSString *title = [block blockTitle]; // Get coordinates of composite block embedded controller CGRect dataViewRect = [block dataViewRect]; // Get composite block index int index = [block index]; // Get whether to show composite block in the slide mode BOOL visibleInSlideshow =[ block isVisibleInSlideshow]; // Display composite block information in the development environment console NSLog(@"Composite block title: %@", title); NSLog(@"Width of composite block embedded controller: %f", dataViewRect.size.width); NSLog(@"Composite block index: %d", index); NSLog(@"Indicates whether to show composite block in the slide mode: %@", visibleInSlideshow? @"yes": @"no"); // Call the calculationsStart method after the 5 second pause [self performSelector:@selector(calculationsStart) withObject:nil afterDelay:5.0f];
After executing the example the mobile device screen displays a dashboard containing composite blocks:
In 5 seconds after starting the example the loading indicator is displayed for one of the composite blocks:
In 5 seconds the displayed loading indicator is hidden, after that the dashboard is restored to its initial view. The development environment console also displays information about the selected composite block:
Composite block title: GDP per capita, PPP (constant 2005 international $)
Width of composite block embedded controller: 380.000000
Number of dashboard composite blocks: 0
Indicates whether to show the composite block in the slide mode: yes
See also: