开发者

inheritance working on simulator but not on Iphone!

I have come across a weird error... I have a class that extends another, getting some variables from it. Its a really simple one. when i compile the code for the simulator, it works great. When I run in the Iphone, it get an error that states that the vairable is not set!. The code: parent class header:

#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

parent class implementation:

#import "GenericTarefaTableView.h"


@implementation GenericTarefaTableView
@synthesize tarefaMap,tarefaMapOriginal;


@end

child class header:

@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

Child class implementation:

#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!!!!!");
}
}

This compiles fine on the simulator, but when i Try on the IPhone, I get an error saying that the variables tarefaMap is undeclared, and should be declared on the function...

any thoughts?


@interface EditTarefaViewController : GenericTarefaTableView <UITextFieldDelegate , UITextViewDelegate> {

before that line add this

@class GenericTarefaTableView;

then in .m file add

import "GenericTarefaTableView.h"

and change like in viewdidload

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


@implementation EditTarefaViewController

before that u have to import TarefaMap.h and also declare this in EditTarefaViewController.h file with like this

@class TarefaMap;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜