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

  • Home
  • SEARCH
  • 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 6605011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:13:57+00:00 2026-05-25T19:13:57+00:00

i have a static class witch has two property,like below … @interface Global :

  • 0

i have a static class witch has two property,like below …

   @interface Global : NSObject
    {

        BarcodeScanner* scanner;
        NSInteger warehouseID;
    }

    @property(assign) BarcodeScanner* scanner;
    @property(assign) NSInteger warehouseID;


    +(Global *)sharedInstance;

    @end

    #import "Global.h"

    @implementation Global
    @synthesize scanner,warehouseID;

    + (Global *)sharedInstance
    {

        static Global *globalInstance = nil;

        if (nil == globalInstance) {
            globalInstance  = [[Global alloc] init];

            globalInstance.scanner = [[BarcodeScanner alloc] init];

            globalInstance.warehouseID = 1;
        }

        return globalInstance;
    }

    -(void) dealloc
    {
        [super dealloc];
    }

@end

now when i analyze project in Xcode i got warning for memory leak for scanner and warehouseID properties , and when i try to release them in dealloc method like …

[[[Global sharedInstance] scanner]release];

i got warning “incorrect decrement of the reference count of an object…”

how should i resolve this problem.

so thanks for any help.

  • 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-25T19:13:58+00:00Added an answer on May 25, 2026 at 7:13 pm

    The warning is because your code does not match the rules Analyzer uses. To avoid the warning

    1. make the scanner property retain
    2. change the the instantiation or BarcodeScanner to be autorelease
    3. add a release for scanner in dealloc

    Example (reformatted just to save space):

    @class BarcodeScanner;
    @interface Global : NSObject {
        BarcodeScanner* scanner;
        NSInteger warehouseID;
    }
    @property(retain) BarcodeScanner* scanner;
    @property(assign) NSInteger warehouseID;
    
    +(Global *)sharedInstance;
    @end
    
    @implementation Global
    @synthesize scanner,warehouseID;
    
    + (Global *)sharedInstance {
        static Global *globalInstance = nil;
    
        if (nil == globalInstance) {
            globalInstance  = [[Global alloc] init];
            globalInstance.scanner = [[[BarcodeScanner alloc] init] autorelease];
            globalInstance.warehouseID = 1;
        }
         return globalInstance;
    }
    
    -(void) dealloc {
        [scanner release];
        [super dealloc];
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class with both a static and a non-static interface in C#.
i have a class with a static public property called Info. via reflection i
Suppose that I have a Java class with a static method, like so: class
I got a Utility module since VB.NET doesn't have static class like C# and
I have a static class that I would like to raise an event as
i am having a strange problem, i have a static class like this public
I have a public static class in which I would like to have a
I want to create a static class in PHP and have it behave like
Say I have a DLL that has the following static/global: ClassA Object; Along with
Suppose I have two instances of the same class. The class has a pointer

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.