I have typedeffed a C block type that I use commonly, in my project's PCH file:
typedef void (^UserBlock)(PFUser* user);
When I try to define an Objective C method in a header like this:
+(void)ensureUserWithID:(NSString *)userID withCompletion:(UserBlock)completionHandler
I am getting Expected a type
error on UserBlock
. However, if I move the typedef from PCH to beginning of that header file, it compiles (with the warning Redefinition of typedef 'UserBlock' is a C11 feature
. I've cleaned the build folder, deleted derived data, restarted Xcode, but I'm still getting the same error. I've got other definitions in my PCH too, and they are compiling just file. All I'm having trouble is the C block types defined in my PCH. Why am I encountering such behavior? I am on Xcode 5.1.1 and LLVM 5.1.
Found the problem. The header file that I was getting errors on was imported to the PCH file, before the typedefs. I've moved the typedefs above the header import, and the problem was gone.