Hello,
Very new to sensible cocoa, am attempting to use the integrated web service loading to populate a table view.
Example JSON from web service:
{ "results" : [ { "animals" : [ { "AnimalID" : "611", "DOB" : 40968, "Genotype" : "CONEDKI/CONEDKI,WT", "LineName" : "CONJ20", "Sex" : "M", "Status" : "D", "UAI" : 1623848 }, { "AnimalID" : "612", "DOB" : 40968, "Genotype" : "CONEDKI/CONEDKI,WT", "LineName" : "CONJ20", "Sex" : "M", "Status" : "D", "UAI" : 1623849 } ], "container" : { "AnimalCount" : 2, "ContainerID" : 424799, "LineName" : "CONJ20", "OwnerName" : "xyyyde eeer", "ZoneName" : "xe(3.49)" } } ] }
As you can see the structure of a result contains two objects/classes each with attributes. The code below is what I have attempted to use:
self.title = @"Scan Container"; SCWebServiceDefinition *serviceDef = [SCWebServiceDefinition definitionWithBaseURL:@"https://the-url.com" fetchObjectsAPI:@"getContainer.php" resultsKeyName:@"results" resultsDictionaryKeyNamesString:@"container;animals" ]; [serviceDef.fetchObjectsParameters setValue:@"xxx" forKey:@"token"]; [serviceDef.fetchObjectsParameters setValue:@"xxx" forKey:@"containerID"]; self.tableViewModel.enablePullToRefresh = TRUE; SCPropertyDefinition *containerDef = [serviceDef propertyDefinitionWithName:@"container"]; containerDef.title = @"Container Details"; containerDef.type = SCPropertyTypeArrayOfObjects; containerDef.attributes = [SCArrayOfObjectsAttributes attributesWithObjectDefinition:serviceDef allowAddingItems:NO allowDeletingItems:NO allowMovingItems:NO]; SCArrayOfObjectsSection *viewSections =[SCArrayOfObjectsSection sectionWithHeaderTitle:nil webServiceDefinition:serviceDef batchSize:7]; viewSections.itemsAccessoryType = UITableViewCellAccessoryNone; [self.tableViewModel addSection:viewSections];
Running the app; after selecting a result, then selecting 'Container Details' shows a single cell with the raw json as the contents. I think the problem is when I set the SCPropertyDefinition.attributes value I am using attributesWithObjectDefinition but should be something like attributesWithWebServiceDefinition, which doesn't not exist.
Anyone accomplished what I am attempting, or does STV simply not support this? Any help greatly appreciated.
Cheers
-Peter