jcrowson
jcrowson

Reputation: 4290

Numbering TableViewCells without using Core Data

I'm building an app that displays a list of projects. Alongside these projects should exist a number displayed using a label (1,2,3 etc..). I am already using core data to store data for the projects and have toyed with the idea of just creating a new attribute called projectID and storing an int value in there whenever the project is created, however if a project is deleted from the list, the number system will be broken.

Is there an easier way to just show the number of the table view cell when it is displayed?

Upvotes: 0

Views: 62

Answers (2)

Damo
Damo

Reputation: 12890

Okay - tbh - it sounds like you have two different numbers. One which you use which is simply an ordinal and as Ole has said you only need to indicate which project is which - #1, #2, #3 etc.

But that is not the same as a project ID. Project IDs like anything you see that is an ID or key indicator are 1) Unique, 2) never ever ever change & 3) Live on after the project itself dies.

So by all means number the rows in your table but don't confuse that number with a 'Project ID'.

Upvotes: 0

Ole Begemann
Ole Begemann

Reputation: 135550

What about indexPath.row + 1?

Upvotes: 1

Related Questions