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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:08:21+00:00 2026-06-07T19:08:21+00:00

So i just switched from xcode 4.2 to 4.3 and now my old way

  • 0

So i just switched from xcode 4.2 to 4.3 and now my old way of creating/using singletons doesnt work. So i did my research on how to set up a singleton and i have this code here.

GlobalLogin.h

@interface GlobalLogin : UIViewController
+(GlobalLogin *)sharedInstance;
@end

GlobalLogin.m

@implementation GlobalLogin


#pragma mark -
#pragma mark Singleton Methods

+ (GlobalLogin*)sharedInstance {

static GlobalLogin * sharedInstance;
if(!sharedInstance) {
    static dispatch_once_t oncePredicate;
    dispatch_once(&oncePredicate, ^{
        sharedInstance = [[super allocWithZone:nil] init];
    });
}

return sharedInstance;
}

+ (id)allocWithZone:(NSZone *)zone {    

return [self sharedInstance];
}


- (id)copyWithZone:(NSZone *)zone {
return self;    
}

#if (!__has_feature(objc_arc))

- (id)retain {  

return self;    
}

- (unsigned)retainCount {
return UINT_MAX;  //denotes an object that cannot be released
}

- (void)release {
//do nothing
}

- (id)autorelease {

return self;    
 }
#endif

#pragma mark -
#pragma mark Custom Methods

So i have all that okay, but my problem is i cant find anywhere how to access its information in the various view controllers that need to use it. So if someone could point me in the right direction that’d be much appreciated.

  • 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-07T19:08:22+00:00Added an answer on June 7, 2026 at 7:08 pm

    I have no idea why you would call +[super alloc], which should already basically be called by alloc itself, but I think you meant -[super init], which even in itself should already by called by -init. Change your initializer to read

    static GlobalLogin * sharedInstance;
    if(!sharedInstance) {
        static dispatch_once_t oncePredicate;
        dispatch_once(&oncePredicate, ^{
            sharedInstance = [[self alloc] init];
        });
    }
    

    Then override -init and call super:

    -(id)init {
        self = [super init];
        if (self) {
           //initialization code here
        }
        return self;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just switched over from the old png transparency fix using a htc
I just switched from windows (Visual Studio) to Linux (Mint) and now I'm using
I have just started using xcode 4.3.2 on lion (switched from snow leopard) and
I just switched from storing my images uploaded via Carrierwave locally to using Amazon
We've just recently switched over from SVN to Mercurial, but now we are running
I just switched from XAMPP to MAMP and now this rewrite rule does not
I just switched from Xcode 3 to 4. When I attempt to upload an
I just switched from mysql to postgres (yay!) but now on my postgres server
I just switched from using Passenger to using POW because I didn't have to
I just switched the way my wordpress theme loads jQuery from manually loading google's

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.