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

  • Home
  • SEARCH
  • 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 4616736
In Process

The Archive Base Latest Questions

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

I am doing a Cocoa tutorial where I need to count the characters in

  • 0

I am doing a Cocoa tutorial where I need to count the characters in a field, then output something like ‘the_string_i_am_count’ has 21 characters.

I have managed to get the string, count it, and output the count but I have no idea how to output the count along with the string and the other info.

How would I do this?

-(IBAction)countCharacters:(id)sender
{
    //i had to connect this to the class also to make it get the value.
    //NSString *string = [inputField stringValue];

    //get the number of chars
    NSUInteger length = [[inputField stringValue] length];

    [outputField setIntValue:length]; //string];
    //[outputField setStringValue: @"'s' has %d characters.", string, length];
}

Semi working code:

-(IBAction)countCharacters:(id)sender
{
    //i had to connect this to the class also to make it get the value.
    NSString *string = [inputField stringValue];

    //get the number of chars
    NSUInteger length = [[inputField stringValue] length];

    [outputField setStringValue:[NSString stringWithFormat:@"'%s' has %d characters.", string, length]];
}
  • 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-22T02:01:33+00:00Added an answer on May 22, 2026 at 2:01 am
    [outputField setStringValue:[NSString stringWithFormat:@"%@ has %@ characters.", string, length]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was following the tutorial at developer.apple.com for learning Cocoa, and I found something
I was doing some programming in Cocoa Touch and Objective-C, and now I have
I've been doing some cocoa since a week, and I'm getting kinda good with
I am doing manual layouting for my Cocoa application and at some point I
I'm on a project doing an iPhone application. We had a Cocoa consultant come
Doing some jquery animation. I have certain divs set up with an attribute of
In Cocoa/ Objective C I need to be able to programmatically find out which
New to Cocoa, and seem to be missing something. What is the most elegant/idiomatic
I have a Cocoa app which interacts with a server and displays a GUI.
Brad Miller @ Cocoa Dev Central wrote a tutorial regarding Creating PDFs from Cocoa.

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.