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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:55:59+00:00 2026-05-24T23:55:59+00:00

I have spent literally hours and hours trying to find the answer to this.

  • 0

I have spent literally hours and hours trying to find the answer to this. I have tried [what I feel anyway!] to be everything. And I cannot call this method in my code with out getting this error:

Receiver type NSString for instance message does not declare a method with selector returnAsDoubleDigits:

I was trying to refactor my code so I could reuse this method to return single digit numbers (converted to NSString) as double digit strings (i.e. 4 becomes 04).

Please can anyone help me here? Have I even declared it correctly etc.? Thank you so much! 🙂

Call something like:

[doubleDigitString returnAsDoubleDigits: singleDigitString];

Header file:

- (NSString *)returnAsDoubleDigits: (NSString *)digits;

Implementation file:

- (NSString *)returnAsDoubleDigits: (NSString *)digits {
    if (digits.length == 1) return [NSString stringWithFormat: @"0%@", digits];
    else return [NSString stringWithFormat: @"0%@", digits];
}
  • 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-24T23:55:59+00:00Added an answer on May 24, 2026 at 11:55 pm

    Where are you calling it from? in the same class? Is this what you intended?

    NSString* doubleDigitString = [self returnAsDoubleDigits:digits];
    

    You could always use categories too.

    @implementation NSString (mycategory)
    
    
    -(NSString *) returnAsDoubleDigits
    {
       NSString* doubleDigits = nil;
       if (self.length == 1) {
        doubleDigits = [NSString stringWithFormat: @"0%@",
                        self];
       } else {
        doubleDigits = [NSString stringWithFormat: @"0%@",
                          self];
       }
       return doubleDigits;
    }
    @end
    

    and then use

     NSString* doubleDigitString = [singleDigitString returnAsDoubleDigits];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have literally spent hours trying to fix this but cant! Like the title
I have spent 3 days looking this up and I cannot find a solid
I have literally spent hours with JQuery trying to extract a piece of text
I have spent hours trying to fix this problem I have, basically I want
I've spent the last 2 hours trying to find a solution for this and
Have spent an hour trying to solve this - but to no avail. I'm
I have spent hours in this problem and my fellows couldn't help me out.
I have spent about half a day searching for an answer to this question
I have spent about an hour or two trying to find out how to
I have spent the better part of today trying to figure this out and

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.