Creating an Express Report Delegate

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes a method of creating an express report delegate. After starting the example the following operations are executed:

Required Files

It is required to add the following file to the base example Displaying of Express Report:

Source Code

Executing the example requires a file named SplittedListReportCell-procedural.png. Then it is required to create an express report delegate class, which implements methods and properties of the <MAReportDelegate> protocol, to add a class title file to source code of the ViewController class (see the Displaying of Express Report section), and also to place the following code in the body of the executeExample method of the ViewController class:

// Get array of data view controllers
NSArray *controllers =[m_controller dataViewControllers];
// Create an express report delegate instance
MAReportDelegateImpl *reportDelegate = [[MAReportDelegateImpl alloc] initWithDataViewControllers: controllers andMode: 1];
// Set express report view controller delegate
[m_controller setDelegate:reportDelegate];
// Get dictionary for saved report settings
NSDictionary *stateDict = [NSKeyedUnarchiver unarchiveObjectWithData: [[m_controller delegate] reportState]];
// Display number of active report sheet in the development environment console
NSLog(@"Number of active view: %d", [[stateDict objectForKey: @"mode"] intValue]);
// Get dictionary for saving visibility of express report view titles
NSDictionary *titleVisible = [stateDict objectForKey:@"titleVisible"];
// Check if dictionary is empty
if (titleVisible)
{
    // Parse report view controllers in cycle
    for (MADataViewController *controller in controllers)
    {
        // Get and display whether current report view title is visible in the development environment console
        BOOL visibility = [[titleVisible objectForKey:[NSNumber numberWithInt:controller.tag]] boolValue];
        NSLog(@"Whether "%@" view title is visible: %@", [controller title], visibility?@"visible":@"invisible");
    }
}
// Call method for saving current report state
[[m_controller delegate] saveReport];
// Display message on existence of screenshot data in the development environment console
if([[m_controller delegate] screenshot] != nil) NSLog(@"There is screenshot data");
else NSLog(@"Screenshot data is missing")

After executing the example the development environment console displays information obtained from dictionary of saved report settings, the message on existence of express report screenshot data, and also the message on executing the method, which implements operations on saving the current report state:

Active view number: 1

Whether the Grid view title is visible: invisible

Whether the Chart view title is visible: invisible

Whether the Map view title is visible: invisible

Calling of operations for saving current report state

Screenshot data is present

See also:

Example of Component Use