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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:39:25+00:00 2026-06-13T13:39:25+00:00

if (url_leng) { NSString *open_string; if (g_system_status.language_code == 0) open_string = @Open; else if

  • 0
    if (url_leng)
    {
        NSString *open_string;

        if      (g_system_status.language_code == 0)
            open_string = @"Open";
        else if (g_system_status.language_code == 1)
            open_string = @"Abrir";
        [open_string retain];
        [alert addButtonWithTitle : open_string];
        g_scan_result = targ_url;               
    }

Consider the above code segment. My question is about the “retain” statement. Somehow I need the retain statement to make the code work. My only explanation is when open_string goes out of scope, a release call will be made against it. And thus a retain call is needed to hold the value.

Hope somebody could confirm this …

Also wish to ask if release statements for the strings are needed after the conditional block ?


Update : (After reading through your kind suggestions and valuable insights)

Have tried the following amendment :

    if (url_leng)
    {            
        if      (g_system_status.language_code == 0)
            [alert addButtonWithTitle : @"Open"];
        else if (g_system_status.language_code == 1)
            [alert addButtonWithTitle : @"Abrir"];
        else
            [alert addButtonWithTitle : @"Open"];
        g_scan_result = targ_url;               
    }

Everything seems to be ok now (even without the retain statement).

  • 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-13T13:39:26+00:00Added an answer on June 13, 2026 at 1:39 pm

    The retain is definitely not needed in this code. If you are having issues, it is not here. Once open_string is assigned to the alert, you don’t need it anymore. You must have a memory management issue elsewhere.

    Perhaps the issue is if the language_code is other than 0 and 1. In this case you never properly initialize open_string. You should at least assign nil or handle this other case in some way.

    Consider ARC and make your life so much easier.

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

Sidebar

Related Questions

// targ_url is passed in as an address to a NSString pointer. - (long)
url: '/folder/file' + i + '.js', The above url creates file1.js, file2.js etc etc
URL in question: http://bit.ly/PSWSk5 I'm currently coding on the page above when I noticed
url = http://localhost/xml.php?type=xml; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); xmlhttp.open(GET, url, true); xmlhttp.setRequestHeader('Content-Type',
NSString *url = [NSString stringWithString: @mailto:?subject=Wallpapers%203d%20App&body=Have%20fun%20with%20this%20unique%20wallpaper%20app]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]]; I am
URL: http://ws.audioscrobbler.com/2.0/?method=chart.gethypedtracks&api_key=1732077d6772048ccc671c754061cb18&limit=10 From the above url I need to somehow remove the Artist name
URL x.php?foo=100 x.php $x = $_GET['foo']; if ($x = 100) { echo yeah; }else{
NSString *url = [NSString stringWithFormat: @http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f, currentLocation.latitude, currentLocation.longitude, coordinate.latitude, coordinate.longitude]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
url : http://localhost/back-office/index.php/staff/shopping when i change the category on every onchange event i want
URL url = new URL(http://localhost:8080/Work/images/abt.jpg); InputStream in = new BufferedInputStream(url.openStream()); ByteArrayOutputStream out = new

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.