Welcome, Guest
Username Password: Remember me

SCObjectSelectionCell
(1 viewing) (1) Guest

TOPIC: SCObjectSelectionCell

SCObjectSelectionCell 1 year, 3 months ago #1

Hello,

i have the following problem:
There are two classes "customer" and "state". Every customer have a state object. The state object contains an attribute text.
So the user sould be change the state object of an customer, but i think its not possible to do this with SCObjectSelectionCell, right?

If yes, is there a possibility to add this feature to the framework??


Best regards
  • gemuese
  • OFFLINE
  • Senior Boarder
  • Posts: 52
  • Karma: 2

Re: SCObjectSelectionCell 1 year, 3 months ago #2

Hi Julian,

Do you have an existing array of State objects that you need to choose a State from and assign it to a Customer object?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: SCObjectSelectionCell 1 year, 3 months ago #3

Hi tarek,

yes i have an existing array of State objects to chose another State.
  • gemuese
  • OFFLINE
  • Senior Boarder
  • Posts: 52
  • Karma: 2

Re: SCObjectSelectionCell 1 year, 3 months ago #4

Hi Julian,

Yes, what you want is possible, but I know that it's not currently stated in the SCObjectSelectionAttributes documentation. We'll fix that in our upcoming release, and we'll add additional constructors to SCObjectSelectionAttributes that will make it really easy to achieve what you want.

As for now, all you need to do is pass on the array of States to the "items" property of SCObjectSelectionAttributes (inherited from SCSelectionAttributes) in the "Customer" class definition. Here is a code sample:

 
...
SCClassDefinition *customerClassDef =
[SCClassDefinition definitionWithClass:[Customer class]
withPropertyNames:[NSArray arrayWithObjects:@"customerName", @"state", nil]];
SCPropertyDefinition *statePropertyDef = [customerClassDef propertyDefinitionWithName:@"state"];
statePropertyDef.type = SCPropertyTypeObjectSelection;
SCObjectSelectionAttributes *objSelectionAttr = [[SCObjectSelectionAttributes alloc] init];
objSelectionAttr.items = myStateObjectsArray;
objSelectionAttr.itemsTitlePropertyName = @"stateName"; // the name property in the State object
objSelectionAttr.allowMultipleSelection = NO;
statePropertyDef.attributes = objSelectionAttr;
[objSelectionAttr release];
...
 


Please tell me if you need any more help.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
Last Edit: 1 year, 3 months ago by tarekskr.

Re: SCObjectSelectionCell 1 year, 3 months ago #5

I tried the following code, but it doesn't works! This snippet only presents the name property in the table view

 
 
stateObjects = [[ULEntityManager instance] loadObjectsOfClass:[StateModel class] withQueryBuilder:[StateModel defaultQueryBuilder]];
SCClassDefinition *customerClassDef = [SCClassDefinition definitionWithClass:[CustomerModel class] withPropertyNames:[NSArray arrayWithObjects:@"name1",@"state", nil]];
SCPropertyDefinition *statePropertyDef = [customerClassDef propertyDefinitionWithName:@"state"];
statePropertyDef.type = SCPropertyTypeObjectSelection;
SCObjectSelectionAttributes *objSelectionAttr = [[SCObjectSelectionAttributes alloc] init];
objSelectionAttr.items = stateObjects;
objSelectionAttr.itemsTitlePropertyName = @"text"; // the name property in the State object
objSelectionAttr.allowMultipleSelection = NO;
statePropertyDef.attributes = objSelectionAttr;
[objSelectionAttr release];
 
SCObjectSection *section = [SCObjectSection sectionWithHeaderTitle:@"test" withBoundObject:customer withClassDefinition:customerClassDef];
 
 
  • gemuese
  • OFFLINE
  • Senior Boarder
  • Posts: 52
  • Karma: 2

Re: SCObjectSelectionCell 1 year, 3 months ago #6

Hi again Julian,

Would you please elaborate more on what you mean by this code is not working? I've just tested the code myself and it seems to be working perfectly fine. Also, I'd be happy to have a look at your project if you wish (just please send it to our support email).
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
Time to create page: 1.77 seconds