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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:22:50+00:00 2026-05-23T08:22:50+00:00

please look at this code: -(NSString *) myfun:(NSString *)name paramnoone:(int)a paramnotwo:(int)b { static int

  • 0

please look at this code:

-(NSString *) myfun:(NSString *)name paramnoone:(int)a paramnotwo:(int)b {
    static int numberofcall=0;
    if(a>b) {
        return name;
    }

    NSString *secondname = [[NSString alloc]init];
    secondname = [name StringByAppendingString:@"test"];
    numberofcall++;
    return secondname;
}

i have a problem on it, when my code is on “return secondname” next step is going to “return name” on if statement part, im confusing a lot , because c++ does not have this problem,
please help me on solve it,
thanks for ur help and sorry for my bad English.

  • 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-23T08:22:51+00:00Added an answer on May 23, 2026 at 8:22 am

    (Until the question is explained further I can’t really answer the question, but still have valuable infos which justify being posted as an answer, so here it goes.)

    In the line:

    NSString *secondname = [[NSString alloc]init];
    

    You allocate an empty string. But in the very next line:

    secondname = [name StringByAppendingString:@"test"];
    

    You overwrite the pointer secondname to the previously allocated empty string, thus creating a memory leak. Since you do not use the empty string at all, remove the first line and turn the second line into:

    NSString *secondname = [name StringByAppendingString:@"test"];
    

    Edit: Based on comments to the questions, I think what you’re asking is this (correct me if I’m wrong):

    • You are debugging the method.
    • While stepping through the method with the debugger, the flow proceeds normally through the method.
    • But after the numberofcall++; line, the debugger suddenly jumps to the return name; instead of the return secondname; line.

    If that’s what’s happening to you: this is normal behavior, unfortunately. When the debugger reaches a return statement the marker always “jumps” to the first return statement in the method. But even though it doesn’t look that way, your return secondname; statement is really executed.

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

Sidebar

Related Questions

Please look at this code: int page; int stop = FALSE; while (!stop) {
Look please at this code: public static void main(String[] args) { String[] array =
Please take a look on this code: <!DOCTYPE html> <html lang=es> <head runat=server> <title>Main
Take a look at this code please : fighter = [:str => 2, :dex
Please look at simple code below public class A{} public class B: A{} public
i got this code off the internet, i suppose to get a list of
I have a method called getTitle which is in a NSString category, and it
I found this interesting thing when I was trying out the new feature optional
I am creating my own implementation of a weak/strong reference pointer relationship and I
What i'm trying to do is a combination of a mootools class and raphael.

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.