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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:45:26+00:00 2026-05-20T14:45:26+00:00

Hey guys, check this out. I have a function that treats for me a

  • 0

Hey guys, check this out. I have a function that treats for me a string. No matter what it does, i just want to knwo if is possible to this function return the result for the place that it was executed. I mean, check this:

[self priceFormat:@"1"];
priceLabel.text = price;


-(void) priceFormat:(NSString*)price {

price = @"2";

}

I just want to my function treats the string and return it to the same place that it was executed.

Thanks!

  • 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-20T14:45:27+00:00Added an answer on May 20, 2026 at 2:45 pm

    Three ways to do this

    Way one, using a pointer

    - (void)priceFormat:(NSString **)price {
      *price = @"2";
    }
    

    Wat two, using an instance variable

    What you might want instead is an ivar. In the interface (most often the h file) of your class:

    NSString *price;
    

    and in the implementation (the m or mm file):

    - (void)priceFormat:(NSString *)price {
      price = @"2";
    }
    

    I have created an example of this here.


    If you want the price to be available to other objects as well (not just self), you might want to create a property for it and synthesize it. Then use self.price = @"2"; instead. More on this here: http://MacDeveloperTips.com/objective-c/objective-c-properties-setters-and-dot-syntax.html

    Just make sure you make it a copy property (NSString in use)!


    Way three using return

    Note, that you can also return directly from a method:

    - (NSString *)priceFormat:(NSString *)price {
      return @"2";
    }
    
    priceLabel.text = [self priceFormat:@"1"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys. Check out this piece of sample code. #include stdafx.h #include<conio.h> #include<string.h> class
Hey guys, I want to make a function loop over all elements that have
Hey guys I know that this is probably just a simple sql statement but
Hey guys I have an admin page that checks if you are admin before
Hey guys, I want to store a categorized list of URLs. This is an
Hey guys.. Check out the fading grey on top of the page and the
hey guys, I need help considering win32com in Python: I have a routine that
Hey guys I have a bean that comes back and one of the properties
Hey guys check this page . This page has fluid layout now. I applied
Hey guys, I have a problem (again). This time I am trying to use

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.