UA-17470720-3

Jump to content


Photo
- - - - -

I want to use SCPropertyTypeSelection, but unable to use it with Core Data

cells sections core-data

  • Please log in to reply
2 replies to this topic

#1 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 09 October 2012 - 09:15 AM

I would like to use SCPropertyTypeSelection showing a list of accounts from a related Core Data table, and be able to choose one. However, when I write:

accountRelDef.type = SCPropertyTypeSelection;
accountRelDef.attributes = [SCSelectionAttributes attributesWithItems:accountDef allowMultipleSelection:NO allowNoSelection:YES];

It crash and I get the following errormessage:

Incompatible pointer types sending ‘SCEntityDefinition *__strong’ to parameter of type ’NSArray *’

I’ve tried instead to use SCPropertyTypeObjectSelection, but it doesnt seems to fit for a lookup from another Core Data table. It put a badge on the cell and count the accounts I’m having (as it does in taskSteps).
Attached File  Skjermbilde 2012-10-09 kl. 13.10.17.png   6.72K   4 downloads

This is the code:

accountRelDef.type = SCPropertyTypeArrayOfObjects;
accountRelDef.attributes = [SCArrayOfObjectsAttributes attributesWithObjectDefinition:accountDef allowAddingItems:YES allowDeletingItems:YES allowMovingItems:YES];

This actually run, but as said, SCPropertyType doesn’t fit my need.

Thankful for suggestions on how to best represent the model attached with STV 3.0!

Attached File  Skjermbilde 2012-10-09 kl. 13.10.46.png   42K   7 downloads

#2 Morten Jacobsen

Morten Jacobsen

    Experienced Member

  • STV 5.0 Pro
  • PipPipPipPip
  • 52 posts
Reputation: 10
Good

Posted 09 October 2012 - 09:36 AM

I solved it! After all the work with explaining my problem, and then once more looking at STV Core Data App this code suddenly made my day:


SCPropertyDefinition *categoryPropertyDef = [taskDef propertyDefinitionWithName:@"category"];
	categoryPropertyDef.type = SCPropertyTypeObjectSelection;
	SCObjectSelectionAttributes *selectionAttribs = [SCObjectSelectionAttributes attributesWithObjectsEntityDefinition:categoryDef usingPredicate:nil allowMultipleSelection:NO allowNoSelection:NO];
selectionAttribs.allowAddingItems = YES;
selectionAttribs.allowDeletingItems = YES;
selectionAttribs.allowMovingItems = YES;
selectionAttribs.allowEditingItems = YES;
selectionAttribs.placeholderuiElement = [SCTableViewCell cellWithText:@"(no categories defined)" textAlignment:UITextAlignmentCenter];
selectionAttribs.addNewObjectuiElement = [SCTableViewCell cellWithText:@"Add new category"];
categoryPropertyDef.attributes = selectionAttribs;


To the developers: The documentation and sample code seems to be way more mature. I'm delighted to be able to find my way using it. STV is so awesome promising. But still a hard nut to crack for a database programmer coming from Windows!

Congratulation with the 3.0 version!

Edited by Morten Jacobsen, 09 October 2012 - 09:38 AM.

  • Tarek and David DelMonte like this

#3 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 12 October 2012 - 04:02 AM

Thanks Morten! :)

To the developers: The documentation and sample code seems to be way more mature. I'm delighted to be able to find my way using it. STV is so awesome promising. But still a hard nut to crack for a database programmer coming from Windows!


Any ideas for us on how to make it simpler for you? Thanks again!





Also tagged with one or more of these keywords: cells, sections, core-data

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users