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

The Archive Base Latest Questions

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

within the applicationDidEnterBackground method my program receives the bad signal EXC_BAD_ACCESS error. on the

  • 0

within the applicationDidEnterBackground method my program receives the bad signal “EXC_BAD_ACCESS” error. on the [self goingOffline]; line

-(void)goingOffline
    {
        NSLog(@"going offline");
        profileViewController * theController;
        NSArray * viewControllers = rootController.viewControllers;
        for ( UIViewController * viewController in viewControllers ) {
            if ( [viewController isMemberOfClass:[profileViewController class]] ) {
                theController = (profileViewController *)viewController;;
            }
        }

    NSString *userID = theController.userId;

    NSMutableData *data = [NSMutableData data]; 

    NSMutableString *userString = [[NSMutableString alloc] initWithFormat:@"id=%@", userID];

    //NSLog(userString);
    //NSLog(numberString);

    [data appendData:[userString dataUsingEncoding:NSUTF8StringEncoding]];

    NSURL *url = [NSURL URLWithString:@"http://www.blah.net/offline.php"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:data];

    NSURLResponse *response;
    NSError *err;

    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
    NSLog(@"responseData: %@", responseData);

    [userID release];
    [data release];
    [request release];
    [url release];
    [userString release];
    [response release];
    [err release];
    [responseData release];
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
    [self.window addSubview:rootController.view];
    [window makeKeyAndVisible];

    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
     */

    [self goingOffline];
}
  • 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:56:47+00:00Added an answer on May 23, 2026 at 8:56 am

    Some of your variables are autoreleased, so they mustn’t be released (they will be relaeased automatically) :

    • data
    • request
    • url
    • response
    • err
    • responseData

    Plus, userID belongs to another object (theController)

    You only call release when you call

    • alloc
    • new
    • copy
    • retain

    explicitly on a variable, or any method starting by copy/new (copyWithZone:,newWithFoo:)…

    So replace

    [userID release];
    [data release];
    [request release];
    [url release];
    [userString release];
    [response release];
    [err release];
    [responseData release];
    

    By

    [userString release];
    

    since userString is the only variable you alloc explicitly.

    This will fix the issue, and your object should not leak.

    Also theController seems to be an instance variable, so you may want to have ownership on it :

            if ( [viewController isMemberOfClass:[profileViewController class]] ) {
                theController = [(profileViewController *)viewController retain];
            }
    

    Or, if it is a property synthesized with retain

            if ( [viewController isMemberOfClass:[profileViewController class]] ) {
                self.theController = (profileViewController *)viewController;
            }
    

    Instead of

            if ( [viewController isMemberOfClass:[profileViewController class]] ) {
                theController = (profileViewController *)viewController;;
            }
    

    (I just realized you also have two semicolons at the end of the line)

    And add in your dealloc method :

    -(void) dealloc
    {
     //...release the other objects you have ownership on
     [theController release];
     [super dealloc];
    }
    

    If you’re new to Objective-C, you may want to have a look at the Apple documentation about memory management (or any resource on this topic). Try to read it carefully, it’s not very difficult, but it’s the most confusing thing if you don’t do it right.

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

Sidebar

Related Questions

Within my ruby program, I'd like to open an existing PDF file, set the
One method of debugging within the Controllers I have learnt from Django is to
Within a child, I have an XML element with the following structure: <position> <startOffset>*NUMBER*</startOffset>
within my login code (index.php) there is a section for facebook login. it checks
Within VS2010 I'm using a dark/pastel color scheme. SP2010 Feature Designer has a Manifest
Within my view I create a scrollview with a width of 320 and a
Do different threads within a single process have distinct independent file descriptor tables? If
I have several Telerik RadGridViews within a TabControl. Each of these RadGridViews has a
Let's say I have the following within my source code, and I want to
I'd like to validate the workflow within the design surface (in this case, Visual

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.