Welcome, Guest
Username Password: Remember me

Table Cells from Core Data
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: Table Cells from Core Data

Table Cells from Core Data 1 year, 7 months ago #1

Hi, I have an application where the data is stored in CoreData, and for each object I would like one cell in the Table view (displaying the Entities 'Title' attribute for example). Then when you click on a cell it will display/push another view based on what cell/object was selected (a web view).

Can Sensible Table View help with this situation? Any hints on how this is done (I already have CoreData setup and I have the objects in the table, however they display the wrong text in the cell, and when clicked it displays the other fields in the object, as the example video tutorial shows).

Any help or guidance will be appreciated.
  • doom
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
  • Karma: 0
Last Edit: 1 year, 7 months ago by doom.

Re: Table Cells from Core Data 1 year, 7 months ago #2

Hi Hayden,

What you're describing sounds almost identical to the Core Data sample app we ship with STV. Would you please post your class definition code, in addition to which attribute you would like to appear as the cell's text? Thanks!
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: Table Cells from Core Data 1 year, 7 months ago #3

Hi Tarek,

Here is the Class definition:

SCClassDefinition *userDef = 
[SCClassDefinition definitionWithEntityName:@"User"
withManagedObjectContext:managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"firstName",@"lastName",@"userId",nil]];
 
SCPropertyDefinition *firstNamePropertyDef = [userDef propertyDefinitionWithName:@"firstName"];
firstNamePropertyDef.title = @"First Name";
firstNamePropertyDef.type = SCPropertyTypeTextView;
 
SCPropertyDefinition *lastNamePropertyDef = [userDef propertyDefinitionWithName:@"lastName"];
lastNamePropertyDef.title = @"Last Name";
lastNamePropertyDef.type = SCPropertyTypeTextView;
 
SCPropertyDefinition *userId = [userDef propertyDefinitionWithName:@"userId"];
userId.title = @"userId";
userId.type = SCPropertyTypeNumericTextField;


I would like "$FirstName $LastName" to appear as the attribute. However when clicked I'd like it to display a UIView with a WebView or ScrollView based on what row was selected.
  • doom
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
  • Karma: 0

Re: Table Cells from Core Data 1 year, 7 months ago #4

I'll send you now our latest RC version, where you'll be able to specify more than one attribute for the cell's title, each separated by a semi-colon. Here is the code you need to add to your class definition:

 
...
userDef.titlePropertyName = @"firstName;lastName";
...
 


To provide custom behavior when the cell is tapped, please refer to the following post: www.sensiblecocoa.com/forum/sensible-tab...tion-action.html#557

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

Re: Table Cells from Core Data 1 year, 7 months ago #5

Thanks Tarek. One more thing, when I implement the delegate function

- (void)tableViewModel:(SCTableViewModel *)tableViewModel didSelectRowAtIndexPath:(NSIndexPath *)indexPath


How do I get the User object that the indexPath.row corresponds to?
  • doom
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
  • Karma: 0

Re: Table Cells from Core Data 1 year, 7 months ago #6

  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 3.03 seconds