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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:03:15+00:00 2026-06-15T18:03:15+00:00

I have a singleton class called DataManager. This class is used by several other

  • 0

I have a singleton class called DataManager. This class is used by several other classes to deal with loading and saving plist files.

I am adding the ability for DataManager to save screenshots as well as plist files. This requires me to load the view I wish to take a screenshot of. The view I’m loading comes from a controller that imports DataManager.

Obviously this is circular dependency, so I used:

@class GardenView;

However, this resulted in the following errors:

  • Receiver ‘GardenView’ for class message is a forward declaration
  • Receiver type ‘GardenView’ for instance message is a forward
  • declaration Property ‘bounds’ cannot be found in forward class
  • object ‘GardenView’ Property ‘layer’ cannot be found in forward
    class object ‘GardenView’

This seems like it can’t find properties inherited from the UIView superclass. Is this true of forward class declarations?

If I use the standard #import instead of @class, I get:

  • Parse Issue: Expected A Type

for the methods in GardenView referencing Plant (which I am importing just fine):

- (void) addPlantToView: (Plant*) plant;
- (void) addPlantToGarden: (Plant*) plant;
- (void) addPlantToViewAndGarden: (Plant*) plant;

The Plant class DOES import the DataManager, but if I change it to @class, I get:

  • No known class method for selector ‘sharedDataManager’

What is the solution for this problem? The class method is there in the header file (+sharedDataManager). Am I doing something completely wrong?

  • 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-15T18:03:16+00:00Added an answer on June 15, 2026 at 6:03 pm

    You haven’t made it clear where exactly you’re doing the imports vs @class. And I think that’s causing confusion. Here’s what you want to do:

    • In GardenView.h, use @class Plant
    • In Plant.h, use @class GardenView
    • In GardenView.m, use #import "Plant.h"
    • In Plant.m, use #import "GardenView.m"

    This breaks the circular dependency in the headers, but still allows the implementations to see the full information of the dependent class.

    Now the reason why @class alone isn’t sufficient is because all @class Foo does is it tells the compiler “There exists a class named Foo”, without telling it anything at all about the class. The compiler doesn’t know its methods. It doesn’t know its superclass. All it knows is if it sees the token Foo, then that represents a class type. You can use this in header files so you can refer to the class in arguments and return types, but in order to actually do anything with values of that type you still need the full #import. But you can put that #import in the .m file without any problem.

    The only time you need #import instead of @class in your header is if you want to inherit from the class in question. You cannot inherit from forward-declared classes, so you need the full #import. Of course, you may also need the #import if you need access to other types defined in the same header (e.g. structs, enums, etc.), but that’s less common in obj-c.

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

Sidebar

Related Questions

I have a singleton class called SingletonController1. This SingletonController1 instantiates a bunch of others
I have a method in a singleton class, this class its called from a
I have a singleton class for global access to config information. This singleton class
I have a singleton class which is being used throughout the app. I am
The goal is to have a singleton data controller class called FetchData.h/.m that pulls
I have an abstract base class called Curve . There are three classes that
I have a singleton class called Manager that holds a list of object instances:
I have a Singleton class here designed to be inherited by classes wanting to
I have a singleton class where I set up a NSMutableDictionary called completedLevels .
I have a singleton class with this code: manager.h @interface Manager : NSObject {

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.