views:

28

answers:

2

It is my understanding that typedef enums are globally scoped, but if I created an enum outside of the @interface of RandomViewController.h, I can't figure out how to access it from OtherViewController.m. Is there a way to do this?

So... "RandomViewController.h"

#import <UIKit/UIKit.h>

typedef enum {
 EnumOne,
 EnumTwo
}EnumType;

@interface RandomViewController : UIViewController { }

and then... "OtherViewController.m"

-(void) checkArray{
      BOOL inArray = [randomViewController checkArray:(EnumType)EnumOne];
}
+1  A: 

Just import the header.

Chuck
+1  A: 

In OtherViewController.m:

#import "RandomViewController.h"

And you shouldn't name your variable like the type. Rather name it myEnumOne, or whatever you like :)

BOOL inArray = [randomViewController checkArray:(EnumType)myEnumOne];

Can you show us the declaration of the checkArray method? In my understanding it should be

- (BOOL)checkArray:(EnumType)blabla;

You shouldn't need to typecast the argument to EnumType when calling the method (I'm assuming that it's of the type EnumType already).

stigi
I am importing the header, but that doesn't seem to do it. It gives me the error "EnumOne" undeclared.
Adrian Harris Crowne
Nevermind--typos are an amazing roadblock! Thanks for the help.
Adrian Harris Crowne
updated the post. lets figure this out :)
stigi