Data Source Delegate

Description: the class implementing data source delegate protocol.

The DataViewDatasourceExample.h File

#import <Foundation/Foundation.h>
#import "DataViewDatasource.h"
// The class implementing data source delegate protocol
@interface DataViewDatasourceExample : NSObject <DataViewDatasourceDelegate>
// Name of the object that receives messages
@property (nonatomic, assign) NSString *name;
// Receives and processes delegate message about data source event
- (void) dataSourceUpdated: (DataViewDatasource *) dataSource withReason: (int) reason;
@end

The DataViewDatasourceExample.m File

#import "DataViewDatasourceExample.h"
@implementation DataViewDatasourceExample
{
    NSString *m_name;
}
// Receives and processes delegate message about data source event
- (void) dataSourceUpdated: (DataViewDatasource *) dataSource withReason: (int) reason
{
    // Determine code of occurred event
    switch(reason)
    {
        case 1:NSLog(@"%@: Data update event, event code: %d", m_name, reason);break;
        case 2:NSLog(@"%@: Custom event, event code: %d", m_name, reason);break;
        default: break;
    }
}
// Initializes class instance with the specified object name
-(id) initWithName: (NSString *)name
{
    if ((self = [super init]))
    {
        // Set object name value
        m_name = name;
    }
    return self;
}
@end

See also:

Handling of Chart Data Source Events | Working with Table Data Source