Delegate for Working with Conditional Formatting Settings

Description: a delegate used to work with conditional formatting settings before and after their update.

The ConditionalFormattingObserver.h File

#import <MobileAnalysis/NuGridUpdateObserver.h>
#import <MobileAnalysis/NuGridView.h>

@interface ConditionalFormattingObserver : NSObject <NuGridUpdateObserver>

@property(assign) NuGridView *gridView; // Table data view

@end

The ConditionalFormattingObserver.m File

#import "ConditionalFormattingObserver.h"
#import <MobileAnalysis/ScreenWaiter.h>

@implementation ConditionalFormattingObserver {
    ScreenWaiter *m_waiter; // Loading indicator
}


- (void)beforeUpdate:(NSString *)key {
    // Display loading indicator
    if (m_waiter == nil) {
        m_waiter = [ScreenWaiter new];
        [m_waiter startAnimating];
    }
    [m_waiter setFrame: [_gridView frame]];
    [_gridView addSubview: m_waiter];
}

- (void)afterUpdate:(NSString *)key {
    // Delete loading indicator
    if (m_waiter) {
        [m_waiter stopAnimating];
        [m_waiter removeFromSuperview];
        [m_waiter release];
        m_waiter = nil;
    }
}

@end

See also:

Applying of Condition Formatting to Whole Table (Example 1)