Description: class implementing express report delegate protocol.
#import <Foundation/Foundation.h> #import "MAReportDelegate.h" // Class implementing the MAReportDelegate protocol @interface MAReportDelegateImpl : NSObject<MAReportDelegate> // Initial report settings @property (nonatomic, readonly) NSDictionary *reportSettings; // Saved report settings @property (nonatomic, retain) NSData *reportState; // Screenshot data @property (nonatomic, assign) NSData *screenshot; // Check if there is saved report screenshot @property (nonatomic, readonly) BOOL hasScreenshot; // Express report access permissions @property (nonatomic, readonly) MAReportAccessRights *accessRights; // Saves current report state - (void) saveReport; // Saves report to favorites - (void) saveFavoriteWithName: (NSString *)name; @end
#import "MAReportDelegateImpl.h" #import "MADataViewController.h" @implementation MAReportDelegateImpl // Saves current report state - (void) saveReport { // Display message on the saveReport method call NSLog(@"Calling operations on saving current report state"); } // Saves report to favorites - (void) saveFavoriteWithName: (NSString *)name { // Display message on the saveFavoriteWithName call NSLog(@"Calling operations on saving report to favorites"); } // Initializes class instance by means of express report view controller data -(id) initWithDataViewControllers: (NSArray *)controllers andMode: (int)mode { if ((self = [super init])) { // Create a dictionary for saving report settings NSMutableDictionary *dict = [NSMutableDictionary dictionary]; // Set number of express report active view in dictionary [dict setObject:[NSNumber numberWithInt: mode] forKey:@"mode"]; // Create a dictionary for saving whether express report view titles are visible NSMutableDictionary *titleVisible = [NSMutableDictionary dictionary]; // Parse express report views in cycle for (MADataViewController *controller in controllers) { // Save whether express report current view title is visible in dictionary [titleVisible setObject:[NSNumber numberWithBool:controller.isDataViewTitleVisible] forKey:[NSNumber numberWithInt:controller.tag]]; } // Save dictionary of title visibility in report settings dictionary [dict setObject:titleVisible forKey:@"titleVisible"]; // Save formed settings dictionary in the reportState property _reportState = [NSKeyedArchiver archivedDataWithRootObject:dict]; // Get file path NSString *path = [[NSBundle mainBundle] pathForResource:@"SplittedListReportCell-procedural" ofType:@"png"]; // Get file binary data NSData *nsData = [NSData dataWithContentsOfFile: path]; // Set screenshot binary data _screenshot = nsData; // Set initial values of whether screenshot is present _hasScreenshot = YES; } return self; } @end
See also: