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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:50:20+00:00 2026-05-25T20:50:20+00:00

I can’t make the static analyzer ‘like’ this code, but at the same time

  • 0

I can’t make the static analyzer ‘like’ this code, but at the same time I cannot autorelease the object that gets stored into controller, so it is useless for the caller. With these 2 static methods I’ve tried to make it easier to display an activity controller over any view (without blocking tabs).

PZActivityOverlayController *view = [PZActivityOverlayController displayOverView:self.view];
// Later on, when complete
[PZActivityOverlayController remove:view];

Original code:

+ (PZActivityOverlayController *)displayOverView:(UIView *)aView {
  PZActivityOverlayController *controller = [[PZActivityOverlayController alloc] initWithFrame:aView.superview.bounds labelText:@"Loading"];
  [controller viewWillAppear:YES];
  [aView.superview insertSubview:controller.view aboveSubview:aView];
  return controller; // Potential leak of object stored into controller
}

+ (void)remove:(PZActivityOverlayController *)display {
  [display viewWillDisappear:YES];
  [display.view removeFromSuperview];
  [display release]; // However it won't leak because it gets released here
 }

Perhaps I have the chain of responsibility wrong here, but it’s only for convenience. The alternative would be writing what’s in the body of these methods everywhere (which violates DRY too much for me).

  • 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-25T20:50:20+00:00Added an answer on May 25, 2026 at 8:50 pm

    There’s a rule (say, convention) – nonautoreleased objects are returned by methods alloc&init…, new, retain, copy. All the rest methods are HAVE TO return autoreleased object.

    In your case I’d rewrite the code above:

    ....
        return [controller autorelease];
    }
    
    + (void)remove:(PZActivityOverlayController *)display {
        [display viewWillDisappear:YES];
        [display.view removeFromSuperview];
    }
    

    …

    PZActivityOverlayController *view = [[PZActivityOverlayController displayOverView:self.view] retain];
    // Later on, when complete
    [PZActivityOverlayController remove:view];
    
    [view release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you make this R code faster? Can't see how to vectorize it. I
can someone show me the regex for this preg_match. I want to make sure
Can anyone tell me how I can display a status message like 12 seconds
Can I use the following across all browsers? <a href=# onclick=doSomething()>Click here.</a> Is this
Can anyone tell me what's wrong with this robots.txt? http://bizup.cloudapp.net/robots.txt The following is the
Can anyone pls let me know the exact c++ code of case sensitive comparison
Can i get the source code for a WAMP stack installer somewhere? Any help
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
Can someone point to me or explain if this is true, you must not

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.