1

I have defined a callback block for a JSON service like so:

#import "JSONResult.h"
typedef void (^JSONResultHandler)(JSONResult*);

Obviously, the JSONResult typed argument is a custom type and its header file is included where this block is defined. Why do I then get the following error?

/Users/oyvind/code/_objc/JSONService.h:22:35: Unknown type name 'JSONResult'
nordhagen
  • 799
  • 5
  • 18

2 Answers2

3

Are you importing your JSON service class in JSONResult too? Maybe you have a circular reference problem.

If you are importing the JSON service class in JSONResult and that import is absolutely necessary, try using forward declaration to import JSONResult in your .h:

@class JSONResult;

@interface SomeJSONService : NSObject

typedef void (^JSONResultHandler)(JSONResult*);

@end

Double check your imports and class names are OK too.

jere
  • 4,306
  • 2
  • 27
  • 38
0

Check that you have imported the JSONResult.h header correctly in JSONService.h:

#import "JSONResult.h"
sergio
  • 68,819
  • 11
  • 102
  • 123