3

In Xcode 4, I failed to find where to set UITableViewCell's Identifier, can anybody helps me? Thank you very much.

Smeegol
  • 2,014
  • 4
  • 29
  • 44

3 Answers3

5

In code:

myTableViewCell.reuseIdentifier = @"CustomIdentifier";

In the interface design document (right-click and view image to get a bigger picture): Image of Xcode 4 showing location of UITableViewCell identifier

  1. Go to the leftmost tab here, the Project navigator.
  2. Select the .xib file containing your cell design.
  3. Select the UITableViewCell object within the .xib
  4. Make sure the rightmost "View" is showing and then go to the 4th-from-left tab, the Attributes inspector.
  5. The top box labelled "Identifier" is where you enter your identifier.
  • Yeah,I finally find my fault. I use a UIView not a UITableViewCell, that's why I cannot find the Identifier field. Thank you all. – Smeegol Aug 30 '11 at 06:37
  • @MichaelMior Did you set your `@property IBOutlet UITableViewCell` to be `readonly`? –  Jun 05 '12 at 03:21
  • No. Although that's a fair question to ask. I've made dumber mistakes before :) – Michael Mior Jun 05 '12 at 13:16
  • Note that you must create a table view cell in Interface Builder for this to work. Don't create an UIView first and then turn it into UITableViewCell. Create an UITableViewCell straight from the objects library. – Niklas Berglund Sep 24 '12 at 04:39
1

When you create a new UITableViewCell in an interface document, select it, show Utilities by pressing Cmd+Opt+0. Under the "Attributes" inspector the first object is your identifier.

Ricky
  • 3,101
  • 1
  • 25
  • 33
  • I am sorry, but you may mean Xcode 3, I mean Xcode 4. I cannot find identifier you figured out in Xcode 4. – Smeegol Aug 30 '11 at 03:46
  • No, I meant Xcode 4 too. Have you created your UITableViewCell in an interface document? – Ricky Aug 30 '11 at 04:01
  • It should be there, be more attentive. Open the right view in xcode (utilities) and find property identifier. Before this- open .xib file with your cell and click on it in center view. – Nekto Aug 30 '11 at 04:02
0

You can use the attribute named 'tag', type of NSInteger

  • Then how to connect with identifier and tag? – Smeegol Aug 30 '11 at 03:48
  • Sorry for misdirecting. Saw Identifier as id. Read method of 'reuseIdentifier' in UITableViewCell's developer document OR set 'Identifier' attribute in Interface Builder. – tong.zhilian Aug 30 '11 at 06:18