Developer

Demo Data Bundled with the App

You can localize your app's demo data.

Context

If you need only an English offline data set, add the required files to your project, enable demo mode, and set the base URL on the SDMDataSource to point to your SVC document. For example:
[SDMDataSource setDemoMode:YES];
[SDMDataSource setBaseURL:@"http://serviceDocument"];
To enable your app for localized offline data support, proceed in the same manner as when adding localized string resources. Structure localizable demo data the same way you organize your localizable string resources, that is:
- (optional) Bundle

         en.lproj/                  Resources localized for English
                 - (optional)OfflineDataDir
                 Localizable.strings
                 MyApp.nib
                 ...
         de.lproj/                  Resources localized for German
                 - (optional)OfflineDataDir
                 Localizable.strings
                 MyApp.nib
                 ...
         ja.lproj/                  Resources localized for Japanese
                 - (optional)OfflineDataDir
                 Localizable.strings
                 MyApp.nib
                 ...
         ...

You can place your offline demo data in a dedicated bundle; to do so, follow the localizable.strings directory structure shown above.

There are four different approaches for organizing your localizable offline data:

Procedure

  1. Place localizable demo data in the localizable resources folders.
    1. Copy your localized demo XMLs to the appropriate <language_code>.lproj (en.lproj, de.lproj, jp.lproj, and so on) directories. The latest versions of Xcode hide the folder structure, and present a logical view of the localized files. In this case, select your localizable offline XMLs in the project navigator:

      Select offline XMLs

    2. In the right pane, choose Localization, then click Make Localized. Select the language of choice, and click Localize.

      Make Localized

    3. Repeat this for every offline XML file, and each language you want to support.
      As a result, your resource file is localized to the languages you specify:
      Localized Resource File

      The corresponding en.lproj, de.lproj, fr.lproj, and so on directories are created in the file system.

    4. As a last step, overwrite the contents of each directory with your localized XMLs.

      Overwrite Contents

    5. Enable demo mode and pass the base URL to SDMDataSource so it points to your SVC document. For example:
                  [SDMDataSource setDemoMode:YES];
                  [SDMDataSource setBaseURL:@"http://serviceDocument"];
      
  2. Place localizable demo data in a dedicated directory under localizable resources.

    Place Demo Data

    1. Select Create folder references for any added folders when adding the resources. The blue directory icon (“OfflineData”) denotes a real directory, while the yellow icons indicate logical groups.

      Create Folder References

    2. In your code, when you initialize the SDMDataSource library, enable the demo mode, set the base URL to point to your SVC document, and set the demo data directory:
      [SDMDataSource setBaseURL:@"http://serviceDocument"];          
      [SDMDataSource setDemoDataDir:@"OfflineData"];
      [SDMDataSource setDemoMode:YES];
  3. Place localizable data in a dedicated bundle.
    1. Place your demo data in a separate bundle, to prevent it from getting mixed with other resources.

      Demo Data Separate Bundle

    2. Identify the demo data bundle to the framework:
      [SDMDataSource setBaseURL:@"http://serviceDocument"];          
      [SDMDataSource setDemoDataBundleName:@"DemoData"];
      [SDMDataSource setDemoMode:YES];
  4. Pack your app's localizable demo data into a bundle and directory.

    Pack Demo Data

    1. Set the bundle and the demo data directory:
      [SDMDataSource setBaseURL:@"http://serviceDocument"];          
      [SDMDataSource setDemoDataBundleName:@"DemoData"];          
      [SDMDataSource setDemoDataDir:@"OfflineData"];
      [SDMDataSource setDemoMode:YES];

Results

If the demo data for a given localization is missing, the offline data is picked from the main bundle’s root or from the en.lproj directory.