我正在使用一個簡單的核心數據應用程序,該應用程序使用tableview和detail視圖。我收到錯誤消息,指出在對象類型ChildrenTVC中找不到屬性managedObjectContext。問題在於它確實存在。我已經清理了該項目並刪除了派生數據。必須有其他事情正在進行。 這裏是目標首標的代碼:在對象類型中找不到屬性
@interface ChildrenTVC : CoreDataTableViewController <AddChildTVCDelegate>
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
@end
和用於執行文件的代碼:
#import "ChildrenTVC.h"
@implementation ChildrenTVC
@synthesize managedObjectContext = _managedObjectContext;
@synthesize fetchedResultsController = _fetchedResultsController;
這裏是應用程序代理文件,其中的錯誤寄存器:
#import "AppDelegate.h"
#import "ChildrenTVC.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize managedObjectContext = __managedObjectContext;
@synthesize managedObjectModel = __managedObjectModel;
@synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
ChildrenTVC *controller = (ChildrenTVC *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
return YES;
}
錯誤在controller.managedObjectContext。很多這是樣板代碼,所以沒有太多。我只是不知道爲什麼它沒有看到託管對象上下文的屬性。該屬性在代碼中。
更新:
我最終重新創建了文件。我不確定在更改文件時仍然存在哪些引用,但有些內容指向錯誤的文件。我必須清空垃圾才能使新文件正常工作。儘管如此,它似乎現在可以工作。我所做的所有研究結果都揭示了Xcode中有些事情是無法解釋的。
代碼似乎很好..嘗試清理您的項目,如果可能的話再次重新啓動xcode。 –
我清理了項目並重新啓動了Xcode。錯誤仍然存在。這是一個謎。 – attentionjay
可以在這裏輸入確切的錯誤? –