Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5846361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:33:57+00:00 2026-05-22T12:33:57+00:00

I have an NSTableView which displays some information representing a custom object of mine.

  • 0

I have an NSTableView which displays some information representing a custom object of mine. I am not using bindings.

Typically, I create my own NSCells to display data, but for once I’m after an NSTextFieldCell that will display a string value of the object, as well as let the user edit it.

I can successfully add the NSTextFieldCell using the code below, but it is not editable.

NSTextFieldCell *textField = [[NSTextFieldCell alloc] init];
[textField setFont:[NSFont fontWithName:@"Helvetica Bold" size:13]];
[textField setTextColor:[NSColor colorWithDeviceRed:0.1058823529 green:0.2117647059 blue:0.3294117647 alpha:1.0]];
[textField setStringValue:projectName];
[textField setEditable:YES];
[textField setBordered:NO];

[textField drawWithFrame:textRect inView:controlView];
[textField release];

Could someone please help me with this?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:33:58+00:00Added an answer on May 22, 2026 at 12:33 pm

    NSTextFieldCell is implemented with the flyweight pattern (I read about it in the “Cocoa Design Patterns” book) and each column has only one instance of a cell. You can see some kind of evidence of this when you edit it in interface builder. When you click to edit an NSTableView, that single instance of the cell jumps in from where it was before and handles the editing for you.

    As you say, doing this works for the visual appearance (drawing) of the cell, and works for NSTextField as well because each NSTextField must have just one cell per view, and therefore it’s around when you want to edit it.

    However in this case, you are creating a cell, drawing it, then kicking it out of memory by releasing it at the end of your code. So how do you expect this cell which you have set as editable to be around when you try to edit it? It doesn’t exist anymore.

    Try creating a single cell when the table view is set up and setting your custom cell to the
    right table column using this:

    - (void)setDataCell:(NSCell *)aCell
    

    Alternatively you could subclass NSTextFieldCell and do your customization there, and set the cell class for the column in interface builder (or XCode 4 if you’re on the bleeding edge!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSTableView that is done using the typical IB and data bindings.
Current Situation: Direct Binding I have an NSTableView which displays the data that comes
I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains
I have a view-based NSTableView populated custom NSTabelCellView subclass, which are the lowest objects
I have a custom NSTableView subclass which is bound to a data source (an
have written this little class, which generates a UUID every time an object of
I have an NSTableView which is bound to an NSDictionaryController. I have set this
I have a NSTableView with 3 columns. I can sort using any of the
I have a Cocoa project with an object that holds information from a SQLite
I have an NSTableview which s bound to a NSArrayController. The Table/Arraycontroller contains Core

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.