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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:04:04+00:00 2026-06-01T10:04:04+00:00

I have a DataClass.h @interface DataClass : NSObject { } enum knownTypes { type1

  • 0

I have a DataClass.h

@interface DataClass : NSObject
{
}

enum knownTypes
{
    type1 = 0,
    type2,
    type3,
    UnknownType = -1
};

Is there a way I can specify knownTypes in .m file and access from other class.

This is Util class i am creating, hence don’t want to create an object to access the values in this class.

for ex: in TestClass.m , by importing DataClass.h , now i can use the enum values as type1,type2.. but if i declare the enum data in DataClass.m , i could not use those enum values.

  • 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-01T10:04:05+00:00Added an answer on June 1, 2026 at 10:04 am

    This has nothing to do with classes. This is a feature of C.

    If you define a type or an enum in a .h file, you can use it by importing it (#import) where you need it.

    If you define your enum in a .c or .m file, only elements after that definition in the file can use it.

    In your case, it appears that you need the same enum in two different files. Usage is to define that enum in a separate file, e.g., knownTypes.h and import that file in the two files using it: DataClass.m and TestClass.m.

    If TestClass is for testing purpose, then your current organization is OK: enum is declared in DataClass.h and both DataClass.m and TestClass.m import DataClass.h.

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

Sidebar

Related Questions

I have a data class: @interface Car : NSObject { Engine *_engine; } //...
I Create a class named DataClass there i have this method +(NSMutableArray*) returnList :(NSString
I have a very basic data class that is subclassed from NSObject. I declare
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I have public abstract class DataClass { public static bool operator ==(DataClass left, DataClass
I have a wsdl file and i am trying to call it from a
I have a question concerning volatile keyword I can't seem to find an answer
I have Googled and read for hours now and I can't find anyone that
Suppose I have the following: class dataClass { public: int someData; float moreData; void
I have text file(test.data), which include some values and class name, for example 4.5,3.5,U1

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.