Welcome, Guest
Username Password: Remember me

Adding objects using Core Data and SCPropertyTypeObjectSelection
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Adding objects using Core Data and SCPropertyTypeObjectSelection

Adding objects using Core Data and SCPropertyTypeObjectSelection 1 year ago #1

Hi Tarek,

As a first post I believe its almost de-rigeur, and most certainly deserved, to begin with complements on the groundbreaking nature of STV.

I expect to have difficulty using some of the more advanced features to begin with, but I'm totally stumped on something that appears as if it should be simple.

I'm using a core data model with a 1-1 relationship between Trip and Boat. What I'd like to do is have a view to allow a selection of one of a list of all boats - and give the user the option to add a new boat to the list and select that. I see that SCArrayOfObjectsAttributes has an allowsAdding attribute, but SCObjectSelectionAttributes does not.

Here's the relevent code snippet I'm using:

 
SCClassDefinition *boatDef = [SCClassDefinition definitionWithEntityName:@"Boat"
withManagedObjectContext:self.managedObjectContext withPropertyNames:[NSArray arrayWithObjects:@"name", @"make", @"model", nil]];
 
 
SCClassDefinition *tripDef = [SCClassDefinition definitionWithEntityName:@"Trip"
withManagedObjectContext:self.managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"name", @"startDate", @"boat", nil]];
 
SCPropertyDefinition *boatPropertyDef = [tripDef propertyDefinitionWithName:@"boat"];
boatPropertyDef.type = SCPropertyTypeObjectSelection;
boatPropertyDef.attributes = [SCObjectSelectionAttributes attributesWithItemsEntityClassDefinition:boatDef
withItemsTitlePropertyName:@"name"
allowMultipleSelection:NO
allowNoSelection:YES];
 
tableModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
 
SCObjectSection *overviewSection = [SCObjectSection sectionWithHeaderTitle:@"" withBoundObject:self.trip withClassDefinition:tripDef];
[tableModel addSection:overviewSection];
 


Nor in this case is it possible to do something like:

((SCPropertyAttributes*)boatPropertyDef.attributes).allowsAdding = YES;


Am I trying to do something inherently impossible, not yet enabled or most likely what am I doing wrong?

With thanks in advance,

James
  • eddisonj
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Karma: 2

Re: Adding objects using Core Data and SCPropertyTypeObjectSelection 1 year ago #2

Hi James and welcome to our forums!

Having the object selection part is really easy, but adding new items to the selection set has is actually a new feature currently being added to STV's new 2.1 release (I must mention that it has been a popular request since our STV 2.0 release). The 2.1 release is roughly expected in two to three weeks from now. Is this time frame ok with your development requirements?

Thanks a lot for all your complements, we really appreciate it
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Adding objects using Core Data and SCPropertyTypeObjectSelection 1 year ago #3

Hi Tarek,

I'd read and seen on the forums the quality of your support - but to reply in the time frame you just have and at this time of night is just unbelievable. If customer support was an Olympic sport you'd be a Gold medalist.

Yes I can wait 2-3 weeks as I've lots else to get on with. I was already waiting for 2.1 as in another place I'd like to list related 1:n objects without needing to drill down another level - which I saw in posting you've said should also be in 2.1. I'd also like to be able to split a generated detail view into sections as has also been mentioned. (In the meantime duplicating the root SCClassDefinition pointing to the same managedObjectContext and the same Entity name _seems_ to be working although I'd be more comfortable with a method devised by you.)

Its very reassuring to know that its not there so that's why I didn't find it. So thanks again and if you want customers with real scenarios to help beta test 2.1 then I'd be delighted to help if I can.

James
  • eddisonj
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Karma: 2
  • Page:
  • 1
Time to create page: 0.85 seconds