Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes creating a regular report. After starting the example the following operations are executed:
A regular report is created.
Regular report delegate is retrieved.
A new regular report delegate is created.
Regular report object is retrieved from the created delegate.
The new regular report delegate is compared with the delegate obtained from regular report.
The new delegate is set as a regular report delegate.
Regular report viewer view is retrieved from regular report.
Parent report controller is retrieved from the regular report viewer.
Regular report viewer mode value is retrieved.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Displaying of Regular Report section):
-(void)executeExample { if (m_proceduralReportDescriptor->formatVersion() == 1) { // Create a report object SPPLProceduralReport proceduralReport = PPLProceduralReport::proceduralReport(m_proceduralReportDescriptor); MAProceduralReportViewController *proceduralReportController = (MAProceduralReportViewController *)[MAProceduralReportViewControllerFactory createReport:m_proceduralReport]; // Get regular report delegate MAProceduralReportViewControllerDelegateImpl * proceduralReportDelegate1 = [proceduralReportController delegate]; // Create a new regular report delegate MAProceduralReportViewControllerDelegateImpl *proceduralReportDelegate2 = [[MAProceduralReportViewControllerDelegateImpl alloc] initWithProceduralReport:proceduralReport]; // Display comparison result for obtained and new delegates in the development environment console if([proceduralReportDelegate1 isEqual:proceduralReportDelegate2] == YES) NSLog(@"Delegate comparison: objects are equal"); else NSLog(@"Delegate comparison: objects are not equal"); NInteger worksheetsCount = 0; if(proceduralReportDelegate2.proceduralReport->worksheets()->items() != NULL) { worksheetsCount = [proceduralReportDelegate2 proceduralReport]->worksheets()->items()->count(); } NSLog(@"Number of regular report sheets: %d", worksheetsCount); // Set new regular report delegate [proceduralReportController setDelegate:proceduralReportDelegate2]; // Display regular report [self showViewControllerInNavigationController: proceduralReportController]; // Get array of regular report views NSArray *dataViewControllers = [proceduralReportController dataViewControllers]; // Parse regular report views in cycle for(UIViewController *controller in dataViewControllers) { // Check if the current view is a regular report viewer if([controller isMemberOfClass:[MAProceduralReportDataViewController class]]) { // Display information on sheet viewer view [self printMAProceduralReportDataViewControllerInfo: (MAProceduralReportDataViewController *)controller]; } } } if (m_proceduralReportDescriptor->formatVersion() == 2) { // Create a report object SPPLProceduralReport2 proceduralReport = PPLProceduralReport2::proceduralReport(m_proceduralReportDescriptor); MAProceduralReport2ViewController *proceduralReportController = (MAProceduralReport2ViewController *)[MAProceduralReportViewControllerFactory createReport:m_proceduralReport]; // Get regular report delegate MAProceduralReport2ViewControllerDelegateImpl * proceduralReportDelegate1 = [proceduralReportController delegate]; // Create a new regular report delegate MAProceduralReport2ViewControllerDelegateImpl *proceduralReportDelegate2 = [[MAProceduralReport2ViewControllerDelegateImpl alloc] initWithProceduralReport:proceduralReport]; // Display comparison result for obtained and new delegates in the development environment console if([proceduralReportDelegate1 isEqual:proceduralReportDelegate2] == YES) NSLog(@"Delegate comparison: objects are equal"); else NSLog(@"Delegate comparison: objects are not equal"); NInteger worksheetsCount = 0; if(proceduralReportDelegate2.proceduralReport->worksheets()->items() != NULL) { worksheetsCount = [proceduralReportDelegate2 proceduralReport]->worksheets()->items()->count(); } NSLog(@"Number of regular report sheets: %d", worksheetsCount); // Set new regular report delegate [proceduralReportController setDelegate:proceduralReportDelegate2]; // Dsiplay regular report [self showViewControllerInNavigationController: proceduralReportController]; // Get array of regular report views NSArray *dataViewControllers = [proceduralReportController dataViewControllers]; // Parse regular report views in cycle for(UIViewController *controller in dataViewControllers) { // Check if the current view is a regular report sheet viewer if([controller isMemberOfClass:[MAProceduralReportExtDataViewController class]]) { // Display information on sheet viewer [self printMAProceduralReportDataViewControllerInfo: (MAProceduralReportDataViewController *)controller]; } } } } -(void)printMAProceduralReportDataViewControllerInfo: (MAProceduralReportDataViewController *) dataViewController { // Get regular report viewer view MAProceduralReportDataViewControllerBase *reportDataViewControllerBase = (MAProceduralReportDataViewControllerBase *)dataViewController; // Get report parent controller MADataReportViewController *dataReportViewController =[reportDataViewControllerBase reportController]; // Display whether report title is displayed in the development environment console NSLog(@"Whether report title is displayed: %@",[dataReportViewController showTitle]? @"displayed":@"not displayed"); // Display regular report viewer mode in the development environment console NSString *mode = @""; switch([reportDataViewControllerBase mode]) { case kReadMode:mode = @"read mode"; break; case kNoteMode:mode = @"note mode"; break; case kSearchMode:mode = @"search mode"; break; default: mode = @"not specified"; break; } NSLog(@"Regular report viewer mode: %@", mode); }
After executing the example the mobile device screen displays the created regular report:
The development environment console also displays comparison result for the obtained and created regular report delegates; the number of regular report sheets; whether the report title obtained from parent report controller is displayed; regular report viewer value:
Delegate comparison: objects are not equal
Number of regular report sheets: 4
Whether report title is displayed: not displayed
Regular report viewer mode: read mode
See also: