Working with Dashboard Synchronization Indexes

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example displays working with dashboard synchronization indexes. After starting the example the development environment console displays identifier, key and name of the first synchronization index.

Source Code

Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Displaying of Dashboard section):

-(void)executeExample {
    if(m_dashboardReport->hasPlist()) {
        // Get first dashboard synchronization index
        SPPLDashboardSynchronizationIndex indexObject = [self getSynchronizationIndexByIndex: 0];
        // Display information about dashboard synchronization index
        [self showSynchronizationIndexInfo: indexObject];
        } else {
        printf("Dashboard report does not contain settings");
    }
}
// Returns specified synchronization index
-(SPPLDashboardSynchronizationIndex) getSynchronizationIndexByIndex: (int) index {
    // Get array of dictionaries with synchronization index container settings
    SNArray indexDescriptions = m_dashboardReport->synchronizationIndexes()->generatePlist()->qClass<NArray>();
    // Create a container for synchronization indexes based on obtained dictionaries
    SPPLDashboardSynchronizationIndexes indexObjects = PPLDashboardSynchronizationIndexes::synchronizationIndexes(indexDescriptions);
    // Get specified synchronization index
    SPPLDashboardSynchronizationIndex indexObject1 = indexObjects->indexes()->objectAtIndex<PPLDashboardSynchronizationIndex>(index);
    // Create a dictionary with synchronization index settings
    SNMutableDictionary plist1 = indexObject1->generatePlist()->qClass<NMutableDictionary>();
    // Set new identifier value for the first synchronization index
    NSMutableString *newID = (NSMutableString *)indexObject1->id()->nsString();
    [newID appendString:@"_test"];
    plist1->setObjectForKey(NString::stringWithNSString(newID), NStr("id"));
    // Create a second synchronization index object based on dictionary
    return PPLDashboardSynchronizationIndex::synchronizationIndex(plist1);
}
// Displays information about dashboard synchronization index
-(void)showSynchronizationIndexInfo: (SPPLDashboardSynchronizationIndex) indexObject {
    printf("Synchronization index identifier: %s \n", indexObject->id()->UTF8String());
    printf("Synchronization index key: %lld \n", indexObject->key());
    printf("Synchronization index name: %s \n", indexObject->name()->UTF8String());
}

After executing the example the development environment console displays information about the first dashboard synchronization index:

Synchronization index identifier: FACTS_test

Synchronization index key: 1

Synchronization index name: Facts


If the dashboard report does not contain settings, the development environment console displays an appropriate notification.

See also:

Example of pplib++ Library Use