MAF provides several utility libraries, such as the UI Helper, ZIP Helper and MAF Logger.
typedef void (^AlertViewResultBlockType)(int buttonIndex); /** Helper categrory to ease the usage of UIAlertView. */ @interface UIAlertView (MAFUIHelper) /** Creates a new instance of a UIAlertView and shows it. The UIAlertViewDelegate is implemented inside the category and the resultBlock parameter is called back with the pressed button index. @param title: The string that appears in the receiver’s title bar @param message: Descriptive text that provides more details than the title @param block: the result block which will be called when the user presses one of the buttons @param cancelButtonTitle: The title of the cancel button or nil if there is no cancel button @param otherButtonTitles: Titles of additional buttons to add to the receiver, terminated with nil */ + (id)alertViewWithTitle:(NSString *)title message:(NSString *)message resultBlock:(AlertViewResultBlockType)block cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; @end
AlertViewResultBlockType is a completion block; that is, an iOS-provided artifact that can contain almost any valid Objective-C code, with the purpose of referencing Objective-C code blocks to be executed when the called function finishes the execution. MAF calls this block when the user taps a button.
#import "MAFZipFileDescriptor.h" ... // write out temporary because the zipmodule works only on disk files NSString *tmpFilePath = [[NSTemporaryDirectory() stringByExpandingTildeInPath] stringByAppendingPathComponent:@"zippedBundle.zip"]; [customResourceData writeToFile:tmpFilePath atomically:YES]; MAFZipFileDescriptor *zipFileDesc = [[MAFZipFileDescriptor alloc] initWithFileAtPath:tmpFilePath]; NSData* welterData = [zipFileDesc uncompressedEmbeddedFileContentNamed:@"style/Styles.xml"]; [welterData retain];
After unzipping the Styles.xml file, you can parse it with MAFStyleParser. See MAF Skinning on how to parse and load this extracted style file.
#import "MAFLogger.h" … [[MAFLogger sharedInstance] setUsedLoggers:MAFLoggerSDM|MAFLoggerConsole|MAFLoggerFile]; … MafLogonLog(MAFInfoLoggingLevel, @"Upload start with URL: %@", fullBtxPath);
#pragma mark - #pragma mark Enable / disable logging /** * Enables logging for non-critical levels, like warning, notice, info, debug. */ -(void) enableNonCriticalLogging; /** * Disables logging of non-critical messages, like warning, notice, info, debug. */ -(void) disableNonCriticalLogging; #pragma mark - #pragma mark Logging status /** * Returns whether non-critical logs are currently enabled */ -(BOOL) isNonCriticalLoggingEnabled;