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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:58:15+00:00 2026-06-07T08:58:15+00:00

Possible Duplicate: How to convert NSNumber to NSString Segue to pass string from MainViewController

  • 0

Possible Duplicate:
How to convert NSNumber to NSString

Segue to pass string from MainViewController to DetailViewController:

MainViewController.m

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {


    if ([[segue identifier] isEqualToString:@"DetailSegue"]) {

        NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
        DetailViewController *detailViewController = [segue destinationViewController];

//Name:
detailViewController.detailName = [[sortedObjects objectAtIndex:selectedRowIndex.row] valueForKey:@"Name"];

//Attempt with number:
detailViewController.detailPopularity = [[sortedObjects objectAtIndex:selectedRowIndex.row] valueForKey:@"Popularity"];
    }
}

DetailViewController.h

//Name:
@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) NSString *detailName;

//Attempt with number:
@property (nonatomic, strong) IBOutlet UILabel *popularityLabel;
@property (nonatomic, strong) NSString *detailPopularity;

DetailViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];

//Name:    
nameLabel.text = detailName;

//Attempt with number:
popularityLabel.text = detailPopularity;
}

In this example the app crashes because it can’t display a NSNumber in UILabel. I need to see an example on how to convert the NSNumber into a NSString so I can display it in a label, I’ve tried in different ways but I can’t find the right combination to fix the error..

  • 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-06-07T08:58:16+00:00Added an answer on June 7, 2026 at 8:58 am

    I didn’t see your NSNumber part, but this should work:

    Label.text = [NSString stringWithFormat:@"%f",[YourNSNumber doubleValue]];
    

    You can change doubleValue to whatever you need, could be intValue and so on. And you need to do a bit research to see what kind of format of the string you want when you convert a floating point to a string.

    Hope this helps

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

Sidebar

Related Questions

Possible Duplicate: How to convert from int to string in objective c: example code…
Possible Duplicate: Convert from char* to NSString? I have char myChar = 'r' How
Possible Duplicate: convert string to integer in c++ Convert a no. from string to
Possible Duplicate: Convert std::string to const char* or char* void setVersion(char* buf, std::string version)
Possible Duplicate: Convert std::string to const char* or char* i've got a line from
Possible Duplicate: Convert from scientific notation string to float in C# Is it there
Possible Duplicate: convert string to nsdate The NSString has following value '2012-07-11T15:59:16' I am
Possible Duplicate: C++ std::string conversion problem on Windows How to convert std::string to LPCSTR?
Possible Duplicate: Convert some code from C++ to C I've got some code that
Possible Duplicate: C# Cannot convert from IEnumerable<Base> to IEnumerable<Derived> I have D1 and D2

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.