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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:59:04+00:00 2026-06-02T00:59:04+00:00

I have been searching for a solution to this issue for a few days

  • 0

I have been searching for a solution to this issue for a few days and have found some similar posts, but no one seems to have posted a definitive answer to how to stop the instance i’m working with from getting dealloc’d. hopefully I just missed it, or someone can help me stop wracking my brain..

I have a class (LKNetworking) which is declaring that it conforms to the UIAlertViewDelegate protocol. Currently it is a subclass of NSObject, however I have tried UIResponder but either produces the same issue.

Issue is that I create a UIAlert view and set the delegate to self. the UIAlert view shows OK, but then the LKNetworking Class instance that called it gets instantly dealloc’d (as I show in NSLOG) and when I click a button, the message gets sent to a deallocated instance (LKNetworking alertView:clickedButtonAtIndex:]: message sent to deallocated instance 0x6e5ce40)

SO, I have tried to create a property in the .h file as such:

@property (strong, nonatomic) LKNetworking *strongNetworkingProperty

I then try to set my UIAlertView’s delegate to the strongNetworkingProperty ivar and the message seems to go nowhere, so thats no good..

I saw some answers where people say to set the alert views delegate to nil, but that defeats my entire purpose since I need to act accordingly in response to the users selection..

here is the sample code of the LKNetworking method where the alert is called and the delegate method:

-(void)checkGameServerVersion: (float) serverGameVersion {
    if (serverGameVersion == GAMEVER) {
        NSLog(@"matched");
        // Continue flow here..
    } else {
        NSLog(@"not matched");
        //Game version does not match, end game, force upgrade 
        UIAlertView *oldVersion = [[UIAlertView alloc]initWithTitle:@"Ugrade Required" message:@"A new game version is available, Please update your game and try again." delegate:self cancelButtonTitle:@"Quit" otherButtonTitles: nil];
        [oldVersion show];
    }
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"button = %d",buttonIndex);
    if (buttonIndex == 0 ) {
        NSLog(@"pressed button 0, quitting gam");
    }
}
@end

Any suggestions would be greatly appreciated!

Thanks

  • 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-02T00:59:05+00:00Added an answer on June 2, 2026 at 12:59 am

    If you want your LKNetworking to stay around, something needs to keep a reference to it. That something can be the LKNetworking object itself. Set strongNetworkingProperty = self when you create the alert view. This creates a retain cycle that prevents the system from deallocating the LKNetworking object. Then in alertView:clickedButtonAtIndex:, set strongNetworkingProperty to nil to break the retain cycle.

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

Sidebar

Related Questions

I've been searching for a solution to this issue for a few days now.
I have been searching for this solution for some time have not found any
Hi I have been searching a solution to this problem for many days but
I have been searching for a solution for this issue for multiple hours today
I have been searching everywhere but can't seem to find a solution to this
I have been searching for a solution to this for a while and have
I have tried searching the database for a similar issue, but was unsuccessful in
I have been searching around for a solution for quite some time, hoping someone
So I have been searching for a solution for this a while now, and
Have been searching how to convert a dictionary to a string. But the results

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.