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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:21:06+00:00 2026-06-04T18:21:06+00:00

In my AppDelegate, near the end of the init method, I call a [self

  • 0

In my AppDelegate, near the end of the init method, I call a [self setup] method. This method gets a string from a URL, trims it, and assigns the string to a property called _songDirectory.

Here’s how it looks in the header file:

@property (retain) NSString *_songDirectory;

And here is how it is assigned in the [setup] method:

//set a URL string
NSString *urlString = [NSString stringWithFormat:@"http://www.blahblahblah.com/php/dev/blah.php?routine=blah"];

NSMutableString *infoString = [self getInfoStringFromURL: urlString];

//get the song directory as a string from the infostring
NSRange startIndex = [infoString rangeOfString:@"song_directory=="];
NSRange endIndex = [infoString rangeOfString:@"end_of_data=="];

_songDirectory = [NSString stringWithString: [infoString substringWithRange: NSMakeRange(startIndex.location + startIndex.length, endIndex.location - startIndex.location - startIndex.length)]];

NSLog(@"STRING IN APP DELEGATE: %@", _songDirectory);

NSLog prints the correct string when called in the app delegate. However, after I push a new scene I cannot access _songDirectory from it. The following code in the pushed scene yields EXC_BAD_ACCESS:

NSLog(@"STRING IN PUSHED SCENE: %@", [[[UIApplication sharedApplication] delegate] _songDirectory]);

I can use the above statement to get ints from the app delegate but not strings. I would appreciate some insight!

  • 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-04T18:21:09+00:00Added an answer on June 4, 2026 at 6:21 pm

    You’re assigning the string directly to the instance variable and not to the property, therefore the string is not retained. It should be self._songDirectory = ... instead of _songDirectory (and you should probably call the property songDirectory, the leading underscore is usually only used for private instance variables).

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

Sidebar

Related Questions

how to call an AppDelegate method from RootViewController without passing a delegate? Just wondering
My AppDelegate_Phone class has the method -(void)doSomething . How can I call that from
I am using this in my appdelegate's applicationDidFinishLaunching: method to make sure the iPhone
From my appDelegate I load the the homeScreen ViewController like this: UIStoryboard* sb =
In the AppDelegate's didFinishLaunchingWithOptions : [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextChanged:) name:NSManagedObjectContextDidSaveNotification object:nil]; This is so
In the AppDelegate of the BubbleLevel example from Apple they do something like this:
I have a method in my appDelegate which gets latitude and longitude and returns
I have setup coredata in my appDelegate, but it first loads the mainWindow.xib and
I implemented 4 views in AppDelegate depends on requirement it will call the view.I
doing this in AppDelegate: viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; Is there any problem

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.