headerfile not found

烂漫一生 提交于 2019-12-21 20:36:09

问题


I am working on a iphone app and everything went fine untill I tried to import NSFetchedResultsController.h. when I was typing this Xcode completed it for me. But now it gives the error: NSFetchedResultsController.h file not found.

I included it like this:

#import "NSFetchedResultsController.h"

I looked all over the internet for the answer to this, but nothing works. (and a few things need Xcode 4.3 to work).

I am using Xcode 4.2 on Snow Leopard.


回答1:


In fact you really don't need to import the header manually in most cases. just add Coredata.framework to build phases as below:

Now look at left in project navigator, you see CoreData.framework added. open Header folder and simply you can find NSFetchedResultsController.h. For testing its existence, you can type:

CoreData/NSFet

and voila, code suggestion tells you what you wanted . look at the picture below:

IMPORTANT: this is available only for iOS 3 or higher




回答2:


"NSFetchedResultsController.h" is part of the CoreData framework, you have to

#import <CoreData/CoreData.h>

You also have to add the CoreData framework to the libraries that your app is linked with:

  • Select your target in Xcode.
  • Click on "Build Phases".
  • In the "Link Binary With Libraries" section, click on "+" and add "CoreData.framework".



回答3:


Sorry if this discussion is very basic for advanced programmers, but it may be useful for advanced programmers who have recently moved to Cocoa, or for beginners in Cocoa/Xcode. This may worth to have a look.

When you want to add a new header which is not included by default , you can first search google for that class reference in Apple Developer ( you can do that directly from your Xcode > Organizer ( at right top of Xcode window ) You should see a page like this:

Two most important things are : 1- Framework 2- Inherits From and
Then check the framework in your Build Phases> Link Binary With Libraries and add it if not exist. By This , you should never encounter such a problem.




回答4:


Check if the file is exist in the project folder, if yes, go to the project, select the app under targets section, go to build phases, open compile source then add the file NSFetchedResultsController.m.



来源:https://stackoverflow.com/questions/12480882/headerfile-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!