2014-04-09 80 views
0

我有一個基於CoreData的應用程序。在Core Data中,我有一個名爲ZSProduction的實體,它創建一個名爲ZSProductionCD的NSManagedObject子類。這是創建的.h文件。iOS - 在X型對象上找不到屬性 - 繼承屬性

#import <Foundation/Foundation.h> 
#import <CoreData/CoreData.h> 

@interface ZSProductionCD : NSManagedObject 

@property (nonatomic, retain) NSNumber * appVersion; 
@property (nonatomic, retain) id highlightColour; 
@property (nonatomic, retain) NSDate * lastUpdated; 
@property (nonatomic, retain) NSString * notes; 
@property (nonatomic, retain) NSString * owner; 
@property (nonatomic, retain) NSString * productionID; 
@property (nonatomic, retain) NSString * productionName; 
@property (nonatomic, retain) NSNumber * scenesLocked; 
@property (nonatomic, retain) NSNumber * shotNumberingStyle; 
@property (nonatomic, retain) NSNumber * sortIndex; 
@property (nonatomic, retain) NSNumber * status; 
@property (nonatomic, retain) NSString * tagline; 

@end 

我然後用類調用子類ZSProduction此:

#import <Foundation/Foundation.h> 
#import "ZSProductionCD.h" 

@interface ZSProduction : ZSProductionCD 
@end 

原因子類是,我可能會增加一堆的方法&可能是其他性質。這樣,如果我對實體進行更改,我可以寫出一個新的ZSProductionCD類,而不會影響我用ZSProduction所做的工作。

現在是這個問題。我在視圖控制器中使用ZSProduction。但是我遇到了其中一個屬性的問題。

在這個視圖控制器,我宣佈一個屬性:

#import "ZSProduction.h" 

@interface [...] 
@property (strong, nonatomic) ZSProduction *item; 
@end 

再後來,在一個方法:

self.productionNameField.text = self.item.productionName; 
self.shotNumStyleControl.selectedSegmentIndex = [self.item.shotNumberingStyle intValue]; 

而這正是它出錯。的XCode抱怨:

住宅「shotNumberingStyle」上鍵入「ZSProduction *」

注意的對象,它不抱怨的productionName屬性,它正常工作未找到。

在同一個視圖控制器,如果我使用:

self.item.shotNumberingStyle = 0; 

然後我得到同樣的錯誤。但如果我使用:

[self.item setValue:0 forKey:@"shotNumberingStyle"]; 

然後它工作正常。但我可以使用:

self.item.highlightColour = [UIColor whiteColor]; 

根本沒有問題。是什麼賦予了?

任何線索,將不勝感激。

回答

0

嗯,我排序的問題,但我想我會離開這裏,以防其他人有類似的情況。

我意識到繼承的三個屬性沒問題,並且可以訪問,我在早期版本的ZSProduction類中創建的那些屬性 - 沒有使用Core Data的一個 - 我目前正在重構從檔案轉移到CD)。

事實證明,磁盤上的項目subdir中存在舊的ZSProduction.h和ZSProduction.m文件 - 但不是XCode中的文件。似乎XCode正在看這些。舊文件位於項目的根目錄中,而較新的文件位於子目錄(稱爲「模型」)中。我刪除了舊的文件,重新啓動XCode &現在全部都是有趣的噓聲。