2011-04-01 163 views
1

我遇到了一個奇怪的錯誤... 我有一個類擴展另一個,從它得到一些變量。它非常簡單。 當我編譯模擬器的代碼時,它工作得很好。當我在Iphone上運行時,會出現一個錯誤,指出可放棄的內容沒有設置!代碼: 父類的頭:在模擬器上繼承工作,但不在iPhone上!

#import <UIKit/UIKit.h> 
#import "TarefaMap.h" 


@interface GenericTarefaTableView : UITableViewController { 
TarefaMap* tarefaMap; 
TarefaMap* tarefaMapOriginal; 
} 
@property (nonatomic, retain) TarefaMap* tarefaMap; 
@property (nonatomic, retain) TarefaMap* tarefaMapOriginal; 


@end 

父類的實現:

#import "GenericTarefaTableView.h" 


@implementation GenericTarefaTableView 
@synthesize tarefaMap,tarefaMapOriginal; 


@end 

子類的頭:

@interface EditTarefaViewController : GenericTarefaTableView <UITextFieldDelegate , UITextViewDelegate> { 

Tarefa* tarefa; 
NSArray *fieldLabels; 
UITextField *textFieldBeginEdited; 
BOOL isEdit; 
IBOutlet UITableViewCell *cell0; 
IBOutlet UITextView* textView; 
NSManagedObjectContext* context; 



} 

@property (nonatomic, retain) NSManagedObjectContext* context; 
@property (nonatomic, retain) IBOutlet UITextView* textView; 
@property (nonatomic, retain) IBOutlet UITableViewCell *cell0; 
@property (nonatomic, retain) Tarefa* tarefa; 
@property (nonatomic, retain) UITextField* firstField; 
@property (nonatomic, retain) NSArray *fieldLabels; 
@property (nonatomic, retain) UITextField *textFieldBeingEdited; 

@end 

子類實現:

#import "EditTarefaViewController.h" 

@implementation EditTarefaViewController 



@synthesize tarefa, textFieldBeingEdited,firstField,fieldLabels,textView, cell0, context; 
NSMutableArray *textFieldarray; 
UIActionSheet *actionSheet; 
UITableViewCell* cell1; 


- (void)viewDidLoad 
{ 


NSLog(@"ViewDidLoad"); 
[super viewDidLoad]; 
self.tarefaMap=[[TarefaMap alloc] initWithTarefa:tarefa]; 
self.tarefaMapOriginal=[[TarefaMap alloc] initWithTarefa:tarefa]; 

if ([tarefaMapOriginal isEqual:tarefaMap]) { 
    NSLog(@"SOMOS IGUAIS!!!!!"); 
} 
    NSLog(@"Comparando tarefas!!!!!"); 
if ([tarefaMapOriginal isEqualtoTarefaMap:tarefaMap]) { 
    NSLog(@"SOMOS IGUAIS2!!!!!"); 
} 
} 

這款C ompiles罰款在模擬器上,但是當我嘗試在iPhone上,我得到一個錯誤說,變量tarefaMap是未申報的,並應在功能上聲明...

任何想法?

+0

嘗試'[self.tarefaMapOriginal isEqual:方法self.tarefaMap]',也發佈確切的錯誤和它發生什麼線。這有幫助。 – 2011-04-01 13:37:38

+0

這個問題可能來自於您的模擬器版本默認保護的變量以及您的iphone版本中的@private。這只是一個猜測,因爲我不知道你會怎麼做。 – 2011-04-01 13:38:36

回答

1
@interface EditTarefaViewController : GenericTarefaTableView <UITextFieldDelegate , UITextViewDelegate> { 

在該行之前添加此

@class GenericTarefaTableView; 

然後在.m文件添加

import "GenericTarefaTableView.h" 

,並在此之前,改變像viewDidLoad中

NSLog(@"ViewDidLoad"); 
[super viewDidLoad]; 
super.tarefaMap=[[TarefaMap alloc] initWithTarefa:tarefa]; 
super.tarefaMapOriginal=[[TarefaMap alloc] initWithTarefa:tarefa]; 


@implementation EditTarefaViewController 

u必須導入TarefaMap.h,並在EditTaref中聲明與aViewController.h文件中像這樣

@class TarefaMap; 
+0

嘿你有回覆我 – 2011-04-01 15:41:18

相關問題