Sorting and Filtering the List of Hybrid App Packages and Messages

By default, the Hybrid Web Container sorts the list of applications and messages in alphabetical order by package name.

There is no filtering by default.

You can sort and filter this list in any way you want. For example, you can filter Hybrid App packages from appearing according to whatever criteria you specify. You can filter out particular Hybrid App packages by name, or you can sort Hybrid App messages by subject. Hybrid App messages are server-initiated messages associated with a Hybrid App package, and appear in a separate TableView.

The sorting and filtering is done using arrays of NSSortDescriptor and NSPredicate objects, respectively. These arrays can be initialized at application startup, and can also be changed dynamically, giving you the ability to change the sorting or filtering criteria while the application is running.

The HybridAppViewController.h file defines the interface for a Hybrid App object. You can sort and filter the properties of this object.

  1. Locate the HybridAppViewController.h file.
    You do not need to modify this file, but you can view the properties of a Hybrid App object on which you might want to filter or sort.
    This file is included in the HWC/includes directory, but it is not explicitly included in the Xcode project. To get the file to appear in the Xcode editor:
    1. In Xcode, open the HWC.xcodeproj.
    2. Open the WidgetFolderController.h file.
    3. Locate this line: #import “HybridAppViewController.h”, right-click inside the quotes, then select Jump to Definition.
      Xcode opens the file.
  2. Customizations involving filtering and sorting for both Hybrid App packages and messages can be made in the CustomizationHelper.m file.
    1. In Xcode Project Navigator, open the CustomizationHelper.m file, which is located in HWC\Classes.
    2. If you are customizing sorting behavior, locate the IOS_CUSTOMIZATION_POINT_SORTING customization tags that accompany these functions:
      • initializeHybridAppSortingDescriptors
      • initializeMessageSortingDescriptors
      • addHybridAppSortDescriptor
      • addMessageSortDescriptor
      • clearHybridAppSortDescriptors
      • clearMessageSortDescriptors
      Customize the initialize functions to add sort descriptors at application startup. If you want to dynamically change the sorting criteria, you can call the add functions to add a sort descriptor to the end of the array, or you can call the clear functions to start over and then add to a clean array. Typically, you do not need to modify the add or clear functions.

      The sort descriptor array is processed in order, so descriptors that appear toward the end of the array are only used when descriptors earlier in the array result in a tie between two elements. This allows you to sort on multiple property keys.

    3. If you are customizing filtering behavior, locate the IOS_CUSTOMIZATION_POINT_FILTERING customization tags that accompany these functions:
      • initializeHybridAppFilterPredicates
      • initializeMessageFilterPredicates
      • addHybridAppFilterPredicate
      • addMessageFilterPredicate
      • clearHybridAppFilterPredicates
      • clearMessageFilterPredicates
      Customize the initialize functions to add filter predicates at application startup. If you want to dynamically change the filtering criteria, you can call the add functions to add a filter predicate to the end of the array, or you can call the clear functions to start over and then add to a clean array. Typically, you do not need to modify the add or clear functions.
  3. Save the file.
  4. Rebuild the HWC.xcodeproj project.
    1. From the Xcode menu, select Product > Clean.
    2. Select Product > Build.