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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:37:01+00:00 2026-06-17T09:37:01+00:00

I have a method with a return value that I want to call from

  • 0

I have a method with a return value that I want to call from my MainviewController.m. Also, I must pass a value (float) to the method when calling it.
But I’m having trouble with that, I tried to debug and add some breakpoints and NSLog in the method but it appears that the method is not being called, since the debugger doesn’t stop at the breakpoint and doesn’t print the NSLog. (the final print (calculatorScreen.text…) just print (null))

MainViewController.m

currentNumber = currentNumber *10 + (float)[sender tag];
NSNumber *convertedNumber = [[NSNumber alloc] init];
NSString *nf = [convertedNumber customFormatNumber:currentNumber];
calculatorScreen.text = [NSString stringWithFormat:@"%@",nf]; // it's printing (null) :(

NSNumber+FormatNumber.h

@interface NSNumber (FormatNumber)
-(NSString *) customFormatNumber:(float)n1;

NSNumber+FormatNumber.m

-(NSString *) customFormatNumber:(float)n1
{
    NSLog(@" %f" ,n1); // for debug and a breakpoint here
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
        [formatter setMaximumFractionDigits:2];
        [formatter setMinimumFractionDigits:0];
        NSString *nf = [formatter stringFromNumber:[NSNumber numberWithFloat:n1]];
    NSLog(@"Class %@" ,nf); // for debug
    return nf;
}

What am I missing here?

  • 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-17T09:37:01+00:00Added an answer on June 17, 2026 at 9:37 am

    Are you trying to overwrite NSNumber?

    For CustomNumber.h

    @interface CustomNumber:NSNumber
    -(NSString *) customFormatNumber:(float) n1;
    

    For CustomNumber.m

    -(NSString *) customFormatNumber:(float)n1
    {
        NSLog(@" %f" ,n1); // for debug and a breakpoint here
        NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
        [formatter setMaximumFractionDigits:2];
        [formatter setMinimumFractionDigits:0];
        NSString *nf = [formatter stringFromNumber:[NSNumber numberWithFloat:n1]];
        NSLog(@"Class %@" ,nf); // for debug
        [formatter release];
        return nf;
    }
    

    Then in MainViewController.m

    currentNumber = currentNumber *10 + (float)[sender tag];
    CustomNumber *convertedNumber = [[CustomNumber alloc] init];
    calculatorScreen.text = [convertedNumber customFormatNumber:currentNumber];
    

    OR

    In MainViewController.m create the method and then the code will be

    currentNumber = currentNumber *10 + (float)[sender tag];
    calculatorScreen.text = [self customFormatNumber:currentNumber];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JavaScript method that call JQuery.get() and i want to return value
I have a method. I want to return a value not from the main
Suppose I have a method that must return an object (say from a database
I have a method, fetchFromWeb, that returns an object. I want to call this
Out of curiosity...what happens when we call a method that returns some value but
I'm creating a class that will have one public method, which returns a value
I have a utility method which returns a strongly typed value from an old
I have a method that return a complex JSON object. It's a heavy processing
I have a C# class method that return a xml document not file. How
I have Class1 , Class2 , and SubclassOfClass2 . I want to call method

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.