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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:35:37+00:00 2026-06-19T00:35:37+00:00

@interface Connections() { static Connections *this; } @end The above piece of code in

  • 0
@interface Connections()
{
   static Connections *this;
}
@end

The above piece of code in .m file throwing compiler error

Type name does not allow storage class to be specified

at the same time when the

static

key word is removed it works well – which so obvious.
Purpose : I want “Connections” instance static and private.

Why is this behavior, please 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-06-19T00:35:38+00:00Added an answer on June 19, 2026 at 12:35 am

    You cannot declare class-level variables in Objective-C classes; instead you need to “hide” them in the implementation file, often giving them static-scope so they cannot be accessed externally.

    Connections.m:

    #import "Connections.h"
    
    static Connections *_sharedInstance = nil;
    
    @implementation Connections
    
    ...
    
    @end
    

    And if this is a singleton, you typically define a class-level accessor to create the singleton upon first use:

    + (Connections *)sharedInstance
    {
        if (_sharedInstance == nil)
        {
            _sharedInstance = [[Connections alloc] init];
        }
        return _sharedInstance;
    }
    

    (and you’ll need to add the declaration in the .h file):

    + (Connections *)sharedInstance;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: public interface IEntityBase<T> where T : struct, IComparable { T?
interface If { ... } class Impl implements If { ... } function test(type:Class,
The code below contains a whole bunch of error messages, and I can't for
I have strange behavior of the static final values in my interface: public interface
This is what I have so far and I want to save pcd file
I am getting this message in unit test expected:<interface java.sql.Connection> but was:<class com.mysql.jdbc.JDBC4Connection> from
I am getting a nullpointerexception with this line of code Statement stmt = conn.createStatement();
New Library: XParsec This question has lead to a stream-type-independent parsec implementation in F#
Does the close() method of the Closeable interface get called when the Closeable object
I'm automating the download of BIC file, using the Swift Automation Interface Spec The

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.