UA-17470720-3

Jump to content


Photo
- - - - -

using attributesWithObjectDefinition:SCParseComDefinition in SCPropertyDefinition.attributes

web-services

  • Please log in to reply
1 reply to this topic

#1 markr

markr

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 41 posts
Reputation: 5
Good

Posted 15 March 2014 - 12:07 PM

PS - Since my original post - I've also tried using SCPropertyTypeObjectSelection instead of SCPropertyTypeArraryOfObjects.  That does display user interface to select TaskSteps from the rows already entered for class TaskStep using Parse's Data Browser.  However, if TaskStep(s) are selected, the Task is not created or updated upon clicking Done after completing editing.  What should be happening is a Task gets created with the objectId's for the selected TaskStep(s) being put into the taskSteps column of the Task.  Also, for SCPropertyTypeObjectSelection with SCObjectSelectionAttributes:attributesWithObjectsWebServiceDefinition I'm still looking for a way to set allowAddingItems, allowDeletingItems and/or allowMovingItems to true.  

 

Getting the following error message: 

 

**STV** Serialization error: Error Domain=TODO_DOMAIN Code=-1 "Cannot serialize data of type '__NSSetM'" UserInfo=0x8be3f40 {NSLocalizedDescription=Cannot serialize data of type '__NSSetM'}.

 

as well as

 

**STV** Web Service Error: Error Domain=com.alamofire.networking.error Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0xa43d230 {NSErrorFailingURLKey=https://api.parse.co...ask/s3i5yJwwkb, NSLocalizedDescription=Expected status code in (200-299), got 400}
 

 

--- Mark

 

Hello  - 

 

To get started with loading data into parse using an active data connection, I'm working on building the Tasks sample with Steps as the related entity.  I've taken the code from the ParseCom.App example and replaced the .xib with a .storyboard.  I've got that working for savings Tasks with name, description, category and active.  However, when I extend the code in viewDidLoad as on page 26-27 of the Intro PDF, I'm not getting anything for the Steps.

 

The code from my viewDidLoad follows below.  SCParseComDefinition descends from SCDataDefinition so I believe taskStepDef should work for attributesWithObjectDefinition in the SCPropertyDefinition for taskStepsRelDef.

 

Any thoughts or comments would be much appreciated...

 

Thanks,

Mark

 

'''

    SCParseComDefinition *taskStepDef = [SCParseComDefinition definitionWithClassName:@"TaskStep" columnNamesString:@"stepName"
        applicationId:@"...KEY REMOVED..." restAPIKey:@"...KEY REMOVED..."];
    SCPropertyDefinition *taskStepNamePDef = [taskStepDef propertyDefinitionWithName:@"stepName"];
    taskStepNamePDef.title = @"Step Name";
    taskStepNamePDef.type = SCPropertyTypeTextField;
    
    SCParseComDefinition *taskDef = [SCParseComDefinition definitionWithClassName:@"Task" columnNamesString:@"name;description;category;active;taskSteps" applicationId:@"...KEY REMOVED..." restAPIKey:@"...KEY REMOVED..."];
    SCPropertyDefinition *namePDef = [taskDef propertyDefinitionWithName:@"name"];
    namePDef.required = TRUE;
    SCPropertyDefinition *descPDef = [taskDef propertyDefinitionWithName:@"description"];
    descPDef.type = SCPropertyTypeTextView;
    SCPropertyDefinition *categoryPDef = [taskDef propertyDefinitionWithName:@"category"];
    categoryPDef.type = SCPropertyTypeSelection;
    categoryPDef.attributes = [SCSelectionAttributes attributesWithItems:[NSArray arrayWithObjects:@"Home", @"Work", @"Other", nil] allowMultipleSelection:NO allowNoSelection:NO];
    SCPropertyDefinition *activePDef = [taskDef propertyDefinitionWithName:@"active"];
    activePDef.type = SCPropertyTypeSwitch;
    
    SCPropertyDefinition *taskStepsRelDef = [taskDef propertyDefinitionWithName:@"taskSteps"];
    taskStepsRelDef.title = @"Steps";
    taskStepsRelDef.type = SCPropertyTypeArrayOfObjects;
    taskStepsRelDef.attributes = [SCArrayOfObjectsAttributes attributesWithObjectDefinition:taskStepDef allowAddingItems:YES allowDeletingItems:YES allowMovingItems:YES];
    
    SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil webServiceDefinition:taskDef batchSize:0];
    objectsSection.dataFetchOptions.sort = TRUE;
    objectsSection.addButtonItem = self.addButton;
    [self.tableViewModel addSection:objectsSection];
    
    self.tableViewModel.enablePullToRefresh = TRUE;

'''


Edited by markr, 15 March 2014 - 04:49 PM.


#2 markr

markr

    Sr. Member

  • STV 5.0 Pro
  • PipPipPip
  • 41 posts
Reputation: 5
Good

Posted 15 March 2014 - 11:08 PM

Here's my most recent attempt - getting closer but still not working...

 

I've modified the TaskViewController to attempt to use a custom detailViewController for TaskStep Selection as follows.  This displays the list of Tasks.  Selecting a Task shows the detail view controller for name, description, category, active and steps.  Name, description, category and active work fine.  Steps opens a TaskStepSelectionViewController (viewDidLoad code follows below) but also gives the error "***STV*** Warning:  Property 'stepName' does not exist in object '<SCParseComDefinition:0x8f6c680>'."  However - in the debugger in xCode I put a breakpoint at stepsSection.AllowDeletingItems = TRUE (last line in viewDidLoad for the TaskStepSelectionViewController and...0x8f6c680 matches up to taskStepDef which is a SCParseComDefinition  - and, drilling down - taskStepDef -> SCWebServiceDefinition -> SCDictionaryDefinition -> SCDataDefinition -> propertyDefinitions -> [0] -> name -> @"stepName" appears and @"stepName" is also listed as the keyPropertyName and titlePropertyName directly under SCDataDefinition.  The same appears in taskStepStore under taskStepStore -> SCDataStore -> _defaultDataDefinition -> SCWebServiceDefinition and the rest as previous.

 

Is this a bug in STV?

 

Here's viewDidLoad for the TaskViewController:

 

    self.navigationBarType = SCNavigationBarTypeAddRightEditLeft;
    
    SCParseComDefinition *taskDef = [SCParseComDefinition definitionWithClassName:@"Task" columnNamesString:@"name;description;category;active;taskSteps" applicationId:@"...KEY REMOVED..." restAPIKey:@"...KEY REMOVED..."];
    SCPropertyDefinition *namePDef = [taskDef propertyDefinitionWithName:@"name"];
    namePDef.required = TRUE;
    SCPropertyDefinition *descPDef = [taskDef propertyDefinitionWithName:@"description"];
    descPDef.type = SCPropertyTypeTextView;
    SCPropertyDefinition *categoryPDef = [taskDef propertyDefinitionWithName:@"category"];
    categoryPDef.type = SCPropertyTypeSelection;
    categoryPDef.attributes = [SCSelectionAttributes attributesWithItems:[NSArray arrayWithObjects:@"Home", @"Work", @"Other", nil] allowMultipleSelection:NO allowNoSelection:NO];
    SCPropertyDefinition *activePDef = [taskDef propertyDefinitionWithName:@"active"];
    activePDef.type = SCPropertyTypeSwitch;
    SCPropertyDefinition *taskStepsPDef = [taskDef propertyDefinitionWithName:@"taskSteps"];
    taskStepsPDef.title = @"Steps";
    taskStepsPDef.type = SCPropertyTypeArrayOfObjects;
    taskStepsPDef.cellActions.detailViewController = ^UIViewController*(SCTableViewCell *cell, NSIndexPath *indexPath) {
        TaskStepSelectionViewController *taskStepVC = [[TaskStepSelectionViewController alloc] init];
        return taskStepVC;
    };
    // NEXT STEP ONCE THIS WORKS - use a custom cell for taskStepsPDef to store value for taskSteps to Parse as an array of objectId strings but display to user as array of stepName strings
    
    SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil webServiceDefinition:taskDef batchSize:0];
    objectsSection.dataFetchOptions.sort = TRUE;
    objectsSection.addButtonItem = self.addButton;
    [self.tableViewModel addSection:objectsSection];
    
    self.tableViewModel.enablePullToRefresh = TRUE;

 

And here's viewDidLoad for the TaskStepSelectionViewController is:

 

    [super viewDidLoad];
    
    SCParseComDefinition *taskStepDef = [SCParseComDefinition definitionWithClassName:@"TaskStep" columnNamesString:@"stepName" applicationId:@"...KEY REMOVED..." restAPIKey:@"...KEY REMOVED..."];
    SCPropertyDefinition *taskStepNamePDef = [taskStepDef propertyDefinitionWithName:@"stepName"];
    taskStepNamePDef.title = @"Name";
    taskStepNamePDef.type = SCPropertyTypeTextField;
    
    SCWebServiceStore *taskStepStore = [SCWebServiceStore storeWithDefaultWebServiceDefinition:taskStepDef];
    
    SCObjectSelectionSection *stepsSection = [SCObjectSelectionSection sectionWithHeaderTitle:@"Steps Selection" boundObject:taskStepDef selectedObjectPropertyName:@"stepName" selectionItemsStore:taskStepStore];
       stepsSection.allowMultipleSelection = TRUE;
       stepsSection.allowNoSelection = TRUE;
       stepsSection.allowAddingItems = TRUE;
       stepsSection.allowMovingItems = TRUE;
       stepsSection.allowDeletingItems = TRUE;







Also tagged with one or more of these keywords: web-services

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users