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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:42:20+00:00 2026-05-21T07:42:20+00:00

When I construct a dynamic URL using NSString stringWithFormat and then use that value

  • 0

When I construct a dynamic URL using NSString stringWithFormat and then use that value in my XML parser I get random crashes. However if I test it with a constant string it works fine…

This is my code for generating the string,

loginURL = [NSString stringWithFormat:@"%@%@",ScriptURLString,@"authenticate"];

Which results in,

http://edms.digistorm.com.au/test/index.php?s=&sc=D41D8CD98F00B204E9800998ECF8427E&m=authenticate

Then I use it in my XML parser,

XMLReturnData = [[NSMutableArray alloc] init];
xml = [[XMLParser alloc] 
       initWithXMLPath:loginURL 
       lookForElement:@"Authenticate" 
       setCallbackObject:self 
       withSelector:@selector(dataReady) 
       data:XMLReturnData
       ];

For some reason this is causing my app to crash. If I use a constant string like,

loginURL = @"http://edms.digistorm.com.au/test/index.php?s=&sc=D41D8CD98F00B204E9800998ECF8427E&m=authenticate";

it works fine…

loginURL is defined as NSString *loginURL; inside my header file for this view.

Any help or guidance would be much appreciated!

Thanks,
Tim

  • 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-21T07:42:20+00:00Added an answer on May 21, 2026 at 7:42 am

    This shows your string is get released and when you calls it in XML parser it crashes the app.

    actually stringWithFormat gives a autorelease object for string.

    So what you need,make your string as retain property inside .h then synthesize it in .m and release it in dealloc method.

    and also do this,

    in viewDidLoad

    NSString *tempString=[[NSString alloc] init];  //using this because your string is retain type so it prevent increment in retain count.
    self.loginURL=tempString;
    [tempString release];
    

    Now when you use stringWithFormat use like this

    self.loginURL = [[NSString stringWithFormat:@"%@%@",ScriptURLString,@"authenticate"] retain];
    

    It solves your problem.

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

Sidebar

Related Questions

Is anyone using Zend Navigation in conjunction with URLs that require dynamic parameters? Zend_Navigation
I am using a va_list to construct a string that is rendered. void Text2D::SetText(const
Trying to work out a map reduce on mongo that would use field value
Using the System.Linq.Dynamic namespace I am able to construct a generic column list to
Is is possible to construct a regular expression that rejects all input strings?
I'm trying to construct a query that will include a column indicating whether or
I'm writing a construct in PHP where a parser determins which function to call
So I have a PHP file that I use to define all my constants
Is it possible to construct a dynamic query to for a linked server (and
Is there a way in C++ to construct your class such that given a

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.