Generating Objective-C Object API Code Using Sybase Unwired WorkSpace

Use Sybase Unwired WorkSpace to generate object API code containing mobile business object (MBO) references.

Prerequisites

Develop the MBOs that will be referenced in the device applications you are developing. A mobile application project must contain at least one non-online MBO. You must have an active connection to the datasources to which the MBOs are bound.

Task
Unwired Platform provides the Code Generation wizard for generating object API code. Code generation creates the business logic, attributes, and operations for your mobile business object.
  1. Launch the Code Generation wizard.
    From Action
    Mobile Application Diagram Right-click within the Mobile Application Diagram and select Generate Code.
    WorkSpace Navigator Right-click the Mobile Application project folder that contains the mobile objects for which you are generating API code, and select Generate Code.
  2. (Optional; this page of the code generation wizard is seen only if you are using the Advanced developer profile) Enter the information for these options, then click Next:
    Option Description
    Select code generation configuration Select one of:
    • Continue without a configuration – generate device code without using a configuration.
    • Select an existing configuration – either select an existing configuration from which you generate device client code, or create a new configuration. By default, a configuration named Most recent configuration is available.Selecting this option enables:
      • Select code generation configuration – lists any existing configurations, from which you can select and use for this session. You can also delete any existing saved configurations.
      • Create new configuration by clicking the Add button. In the dialog, enter the Name of the new configuration and provide a description, and click Create to save the configuration for future sessions.

        Select an existing configuration as a starting point for this session and click Clone to modify the configuration.

  3. On the Select Mobile Objects page, select all the MBOs in the mobile application project or select MBOs under a specific synchronization group, for which references, metadata, and dependencies (referenced MBOs) are included in the generated device code. Then click Next.
    Dependent MBOs are automatically added (or removed) from the Dependencies section depending on your selections.
    Note: Code generation fails if the server-side (runtime) enterprise information system (EIS) data sources referenced by the MBOs in the project are not running and available to connect to when you generate object API code.
  4. Enter the information for these configuration options:
    Option Description
    Language Select Objective-C.
    Platform Select the platform ( target device) for which the device client code is intended.
    • iOS
    Unwired Server Specify a default Unwired Server connection profile to which the generated code connects at runtime.
    Server domain

    Choose the domain to which the generated code connects. By default, if you specified an Unwired Server to which you previously connected successfully, the first domain in the list is chosen. Accept this domain, or enter a different one.

    Note: This field is enabled only when an Unwired Server is selected.
    Page size

    Not enabled for Objective-C.

    Destination Specify the destination of the generated device client files. Enter (or Browse) to a Project path or File system path (Mobile Application project) location, and select Generated Code as the destination.

    Select Clean up destination before code generation to clean up the destination folder before generating the device client files.

      If you select Java as the language, enter, or browse to the , which adds it to the project build path, and prevents errors after code generation.
  5. Reviewers:
    CR664373-2 updates for steps 7 and 8
    Select Generate metadata classes to generate metadata for the attributes and operations of each generated client object.
    The Including object manager classes option is only available if you select Generate metadata classes.
  6. Click Finish.

    By default, the MBO source code and supporting documentation are generated in the project's Generated Code folder. The generated files are located in the <MBO_project_name> folder under the includes and src folders. The includes folder contains the header (*.h) files and the src folder contains the implementation (*.m) files.

    Because there is no namespace concept in Objective-C, all generated code is prefixed with packagename. For example, "SampleApp".


    SampleApp generated code for iPhone
    The frequently used Objective-C files in this project, described in code samples include:
    Source Code File Descriptions
    Objective-C File Description
    MBO class (for example, SampleAppCustomer.h, SampleAppCustomer.m) Include all the attributes, operations, object queries, and so on, defined in this MBO.
    synchronization parameter class (for example, SampleAppCustomerSynchronizationParameter.h, SampleAppCustomerSynchronizationParameter.m) Include any synchronization parameters defined in this MBO.
    Key generator classes (for example, SampleAppKeyGenerator.h, SampleAppKeyGenerator.m) Include generation of surrogate keys used to identify and track MBO instances and data.
    Personalization parameter classes (for example, SampleAppPersonalizationParameters.h, SampleAppPersonalizationParameters.m) Include any defined personalization keys.
    Note: Do not modify generated MBO API generated code directly. For MBO generated code, create a layer on top of the MBOs using patterns native to the mobile operating system development to extend and add functionality.
  7. Examine the generated code location and contents.
  8. Validate the generated code.