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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:43:46+00:00 2026-06-14T04:43:46+00:00

im trying this: NSNumber *num1; NSNumber *num2; self.addNumberOfRoundsText.text = [num1 stringValue]; self.numberOfRoundsText.text = [num2

  • 0

im trying this:

    NSNumber *num1;
    NSNumber *num2;
    self.addNumberOfRoundsText.text = [num1 stringValue];
    self.numberOfRoundsText.text = [num2 stringValue];
    NSNumber *sum = [NSNumber numberWithInt:([num1 intValue] + [num2 intValue])];
    NSLog(@"%@", [sum stringValue]);

For some reason, the console keeps outputting 0 im not sure if there is something i am missing. I just want to get the text from two UITextField’s and add them. Then output them to the console. Thank you for the help!

  • 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-14T04:43:48+00:00Added an answer on June 14, 2026 at 4:43 am

    In your example code, you haven’t initialized num1 and num2. So (if you are using ARC, which is the default for new projects), those variables are initialized to nil.

    In Objective-C, you can send any message (like stringValue or intValue) to nil, and it will return 0 or nil back. So:

    NSNumber *num1; // initialized to nil by ARC
    NSNumber *num2; // initialized to nil by ARC
    
    // This sets self.addNumberOfRoundsText.text to nil.
    self.addNumberOfRoundsText.text = [num1 stringValue];
    
    // This sets self.numberOfRoundsText.text to nil.
    self.numberOfRoundsText.text = [num2 stringValue];
    
    // This gets 0 for [num1 intValue] and 0 for [num2 intValue], which add up
    // to 0, so sum is an NSNumber representing zero.
    NSNumber *sum = [NSNumber numberWithInt:([num1 intValue] + [num2 intValue])];
    NSLog(@"%@", [sum stringValue]);
    

    I’m not sure what you’re actually trying to do. Maybe you have two text fields, and each text field contains a number, and you want to add up those two numbers. If that’s what you want to do, try this:

    int n1 = self.addNumberOfRoundsText.text.intValue;
    int n2 = self.numberOfRoundsText.text.intValue;
    int sum = n1 + n2;
    NSLog(@"sum = %d", sum);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to convert id* to NSNumber * trying this unsigned int ShortValue =
I'm doing this : for(int k=0;k<[dataWord count];k++) { NSNumber *num=[NSNumber numberWithInt:2] ; [preDataWord insertObject:num
I am trying to put a NSNumber to an array with this: NSNumber *n
I'm trying to switch views in my app using this chunk of code: self->variable1
I'm trying to format large currency numbers like this: NSNumber *testVal = [NSDecimalNumber decimalNumberWithString:
After trying this simple console input with 5, the result is shown as 53
Im trying this, but when i press it it dont changes, it only displays
I'm currently trying this: using DocumentFormat.OpenXml.Packaging; using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(fileNameDocx as string, true))
I am trying this import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream;
I've being trying this for about 5 hours already, and I'm feeling really, really

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.