Adding Core Data to existing project in XCode 4

前端 未结 6 1322
一向
一向 2021-02-01 17:02

I started off the project without Core Data and now I would like to add that functionality to my apps. How do I do this?

What additional things does XCode sets up when

6条回答
  •  情深已故
    2021-02-01 17:42

    One trick is to just create a new empty project with Core Data support. That will give you the necessary code that you can copy over to your original project and compile.

    The only gotcha is that you need to handle the Core Data header file. Xcode puts it in the precompiled header files when it generates files using the templates. So you can add the following line to your .pch file:

    #import 
    

    or you can just add it to the .m files where needed.

    It works like a charm. Notice Luka's comment below about how to do it in Xcode5.

提交回复
热议问题