Welcome, Guest
Username Password: Remember me

Grouping items by Field Title
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Grouping items by Field Title

Grouping items by Field Title 1 year, 4 months ago #1

Afernoon

I have the following code:

// Create the AuditEntity definition
SCClassDefinition *auditDef = [SCClassDefinition definitionWithEntityName:@"AuditEntity" withManagedObjectContext:self.managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"title", nil]];

tableModel = [SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];

SCArrayOfObjectsSection *auditsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil
withEntityClassDefinition:auditDef];
auditsSection.addButtonItem = self.navigationItem.rightBarButtonItem;
[tableModel addSection:auditsSection];


If I add the same entry into the filed under Title, I get two entries, whereas I would like to get one.

What is the best way to do this ?

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Grouping items by Field Title 1 year, 4 months ago #2

Hi Iain,

I am not sure I understand your question, would you please elaborate?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Grouping items by Field Title 1 year, 4 months ago #3

Hi Tarek

What I was trying to say is that if I add in two cells with the same title, I get two entries. What I was hoping to get was just one title with two separate entries.

Iain
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Grouping items by Field Title 1 year, 4 months ago #4

Do you mean you want to ignore any new items added if they have the same Title as any of the existing items?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72

Re: Grouping items by Field Title 1 year, 4 months ago #5

Hi Tarek

I don't want to ignore it, but want to then have it as a group listing.
  • ihmunro
  • OFFLINE
  • Expert Boarder
  • Posts: 135
  • Karma: 0

Re: Grouping items by Field Title 1 year, 4 months ago #6

I will assume that by "group listing" you mean a table view section. In that case, you need to use an SCArrayOfObjectsModel instead. An SCArrayOfObjectsModel automatically generates the sections for you according to your custom criteria. For a detailed example on this, please check the "Core Data App" sample application, under the "People" tab. You'll find that the model automatically creates a new section for each alphabet letter.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2404
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 0.88 seconds