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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:27:13+00:00 2026-05-23T05:27:13+00:00

I have a method named -( void ) loadUrl:(NSString *) SearchStr .In that i

  • 0

I have a method named -( void ) loadUrl:(NSString *) SearchStr.In that i assign value to the global nsstring

variable. Then i call Apple’s network reachability class methods using [self checkReach].

In that function i can able to print that nsstring variable. and again the

- (void) checkNetworkStatus:(NSNotification *)notice; metod is called.

In that function i cant able to print that nnstring varibale.
This crashes my application.

I dont know, why this global variable is not accesible in the - (void) checkNetworkStatus:(NSNotification *)notice; method?

Any helps would be greatly appreciated!

Thanks for your time.

Find the code below;-

#in the header file.
@property(nonatomic, retain) NSString* myEscapedUrlString;

#in the m file
@synthesize  myEscapedUrlString;

-( void ) loadUrl:(NSString *) SearchStr
{
  myEscapedUrlString  = SearchStr;

  NSLog(@"%@ ###########",myEscapedUrlString);

  [self checkReach];
}

-(void)checkReach
//----------------
{
  NSLog(@"%@ nnnnnnnnnnnnnnnnn",myEscapedUrlString);

  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(load_View) name: UIApplicationDidBecomeActiveNotification object:nil];

  // check for internet connection
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];

  internetReachable = [[Reachability reachabilityForInternetConnection] retain];
  [internetReachable startNotifier];

  // check if a pathway to a random host exists
  hostReachable = [[Reachability reachabilityWithHostName: @"www.testn.com"] retain];
  [hostReachable startNotifier];

}

- (void) checkNetworkStatus:(NSNotification *)notice;
//---------------------------------------------------
{
      NSLog(@"%@ nnnnnnnnnnnnnnnnn",myEscapedUrlString);
    NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];

    NetworkStatus hostStatus = [hostReachable currentReachabilityStatus];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:kReachabilityChangedNotification object:nil];


    if (internetStatus == NotReachable)
    {
        NSLog(@"The internet is down.");
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Status" 
                                                        message:@"Internet connection is not availbale. Check your connections." delegate:self 
                                              cancelButtonTitle:nil otherButtonTitles:@"OK", nil];

        [alert show];
        [alert release];


    }
    else if (hostStatus == NotReachable)
    {
        NSLog(@"A gateway to the host server is down.");
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Network Status" 
                                                        message:@"Cannot connect to Aghaven server. Please try again later." delegate:self
                                              cancelButtonTitle:nil otherButtonTitles:@"OK", nil];

        [alert show];
        [alert release];

    }




}
  • 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-23T05:27:14+00:00Added an answer on May 23, 2026 at 5:27 am

    You should retain the string value. Do this in loadUrl:

    self.myEscapedUrlString  = SearchStr; 
    

    instead of

    myEscapedUrlString  = SearchStr;
    

    And it is preferable to declare NSString properties to be copy rather than retain. This way even if the original string were mutable, our instance will remain unchanged.

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

Sidebar

Related Questions

Welcome! I have a recursive public static method named less that takes a tree
Let's say I have a structure named vertex with a method that adds two
I have the following extension method: public static void ThrowIfArgumentIsNull<T>(this T value, string argument)
I have a method named 'PersonsMeeting' that gets as parameter ObservableCollection of Person. Can
I Create a class named DataClass there i have this method +(NSMutableArray*) returnList :(NSString
I have this class with an instance method named open and need to call
I want to pass an NSString to a method and have that particular NSString
I have a method named RenderContent which returns object[] In my unit test, I
I have a method that needs to accept an array of country names, and
I have 2 classes, Parent and Child, and Parent has a class method named

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.