Welcome, Guest
Username Password: Remember me

Cell title from sub entity relationship property
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Cell title from sub entity relationship property

Cell title from sub entity relationship property 1 year, 8 months ago #1

Hi again!

Delving deeper into the migration/coding of our app with your wonderful Sensible Framework. I was wondering if it was possible to set the title of a cell (core data entity) to one of its relationship property?

Ex.:

HouseEntity -> AdressEntity

In this example house as a one to one relationship to adress. I need that each house cell in the tableview gets its title from the adresse relationship property "street". I thought of using key value coding principles with SCClassDefinition/SCPropertyDefinition (ex.: @"adress.street") but to no avail.


Regards,
  • codebonbon
  • OFFLINE
  • Expert Boarder
  • Posts: 147
  • Karma: 7
Last Edit: 1 year, 8 months ago by codebonbon.

Re: Cell title from sub entity relationship property 1 year, 8 months ago #2

Hi codebonbon,

Just set the SCClassDefinition property called titlePropertyName to the name of the attribute you want the cell text to show.

Hope this helps
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Cell title from sub entity relationship property 1 year, 8 months ago #3

Hi again!

Tried it but i get the memory adresse of the property rather then its value (something like <Adresse: 0x700c590> enti...) in the title now. Is it the the class definition of the sub entity (which is a relationship) that is causing the problem? Or maybe my property def? Again my Propriete Entity as a one to one relationship with my Adresse Entity. I need the Adresse Entity's "Rue" property to show up as a title to the Propriete Entity.

 
- (void)viewDidLoad {
[super viewDidLoad];
 
// Set up the edit and add buttons.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
 
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
 
// Creation de nouvelles instances des entites
AppDelegate_Shared *appDelegate = [[UIApplication sharedApplication] delegate];
self.managedObjectContext = [appDelegate managedObjectContext];
 
 
// Create a class definition for AdresseEntity
SCClassDefinition *adresseDef =
[SCClassDefinition definitionWithEntityName:@"Adresse"
withManagedObjectContext:self.managedObjectContext
withPropertyNames: [NSArray arrayWithObjects:@"rue", @"ville", @"province",@"pays",@"codePostal", nil]];
adresseDef.titlePropertyName = @"rue";
 
// Create a class definition for ProprieteEntity
SCClassDefinition *proprieteDef =
[SCClassDefinition definitionWithEntityName:@"Propriete"
withManagedObjectContext:self.managedObjectContext
withPropertyNames: [NSArray arrayWithObjects:@"adresse", nil]];
 
SCPropertyDefinition *adressePropertyDef = [proprieteDef propertyDefinitionWithName:@"adresse"];
adressePropertyDef.attributes = [SCObjectAttributes attributesWithObjectClassDefinition:adresseDef];
 
// Instantiate the tabel model
tableModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
 
// Create and add the objects section
SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil
withEntityClassDefinition:proprieteDef];
 
 
objectsSection.addButtonItem = self.navigationItem.rightBarButtonItem;
[tableModel addSection:objectsSection];
}
 



Thanks!
  • codebonbon
  • OFFLINE
  • Expert Boarder
  • Posts: 147
  • Karma: 7
Last Edit: 1 year, 8 months ago by codebonbon.

Re: Cell title from sub entity relationship property 1 year, 8 months ago #4

I will now send you an RC version of our next release, where all you need to achieve what you want is:

 
adresseDef.titlePropertyName = @"rue.adresse";
 


Please tell me if this worked out well for you.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Cell title from sub entity relationship property 1 year, 8 months ago #5

Wonderful!

It worked though i had to set

proprieteDef.titlePropertyName = @"adresse.rue";


Does this mean that the new version is "kvc" compliant troughout?

Cheers!
  • codebonbon
  • OFFLINE
  • Expert Boarder
  • Posts: 147
  • Karma: 7

Re: Cell title from sub entity relationship property 1 year, 8 months ago #6

Glad it worked. And yes, the new version fully supports the dot convention in KVC when it comes to Core Data objects.

BTW, yes it's "adresse.rue". Sorry I don't know French, and now that I looked up what rue means, it makes much more sense this way
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
Time to create page: 3.28 seconds