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 1080503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:02:40+00:00 2026-05-16T22:02:40+00:00

I am using an NSTokenField as a way for users to enter tags. Everything

  • 0

I am using an NSTokenField as a way for users to enter tags. Everything works fine and it hooks up with CoreData managing the tags both when the user adds or deletes a tag.

I recently added logic so that the NSTokenField would resize vertically as the user adds tags and they break to the next line using Andrew Bowman’s IFVerticallyExpandingTextField. Again this all works fine.

The issue is that when I have to initially populate the NSTokenField with tags, I need it to resize. I populate the field by calling:

[tagField setObjectValue: anArray];

Where anArray is a series of objects that represent a tag or a Token. This in turn calls the NSTokenField delegate method

tokenField:displayStringForRepresentedObject:

Which returns the string representation for the object passed in the previous array.

I need to resize the NSTokenField after all of the calls to displayStringForRepresentedObject. Does anyone have any ideas of a notification or a way of finding out that it’s all done? Even a way of calling the resize in between each call to displayStringForRepresentedObject would probably work.

Thanks in advance.

  • 1 1 Answer
  • 0 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-16T22:02:40+00:00Added an answer on May 16, 2026 at 10:02 pm

    You might try something similar to -setNeedsDisplay: and -displayIfNeeded … i.e., -setNeedsSizeToFit: and -sizeToFitIfNeeded.

    You’ll just need a “needsSizeToFit” BOOL flag and the -setNeedsSizeToFit: and -sizeToFitIfNeeded methods.

    After you set your tokens, call -setNeedsSizeToFit:YES. It in turn will set the instance’s needsSizeToFit flag, then if the flag is YES, it will call [self performSelector:@selector(sizeToFitIfNeeded) withObject:nil afterDelay:0]. Your -sizeToFitIfNeeded method will check if your needsSizeToFit flag is YES, call [self sizeToFit], then set the needsSizeToFit flag to NO.

    Update

    Here’s a complete class (JLNAutoSizingTokenField) that does basic autosizing as described above. The only augmentation was to call this in the afore-mentioned delegate method:

    - (NSString *)tokenField:(NSTokenField *)aTokenField 
    displayStringForRepresentedObject:(id)representedObject
    {
        [(JLNAutoSizingTokenField *)aTokenField setNeedsSizeToFit:YES];
        return representedObject;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSTokenField in a window. I am using it to store tags
Using online interfaces to a version control system is a nice way to have
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using C#, I need a class called User that has a username, password, active
I have a button that adds a token to a NSTokenField. It adds the
Using Javascript, is there a standard way to get the absolute path of an
Using a site like StackOverflow as an example: I have a table of users,
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the

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.