Riq Hopkins
Riq Hopkins

Reputation: 43

Determine from code if Core Data framework is present

I have a class that I need to use in both Core Data and non Core Data applications. In non Core Data applications I need the class to omit certain code at compile time. Are there any compiler directives that detect if Core Data framework is added to the Xcode project, something like #ifdef __COREDATA?

Upvotes: 2

Views: 144

Answers (2)

Peter DeWeese
Peter DeWeese

Reputation: 18333

There is a way:

#if NSCoreDataVersionNumber
//my code
#endif //NSCoreDataVersionNumber

And

#ifdef _COREDATADEFINES_H
  //my code
#endif

Upvotes: 2

joelm
joelm

Reputation: 8771

You could just test for a class and see if it's defined.

if ([NSFetchRequest class] == nil) 

Upvotes: 0

Related Questions