2009-12-30 64 views
0

我有这两个类MobRec & MobDef,我想引用MobRec中的(MobDef)* mobInfo数组指针。 #输入MobRec.h或.m中的mobdefs.h文件,但没有运气有任何想法?Objective C一个类没有看到其他的

MobRec.h 
// Basic class unit 
@interface MobRec : NSObject { 
NSString *mName; 
int speed; 
} 
@end 

MobDef.h 
// Master Class holding an array of units 
@interface MobDef : NSObject { 
NSMutableArray *mobInfo; 
} 

@property(retain) NSMutableArray *mobInfo; 
@end 

MobDef.m 
@synthesize MobInfo; 

- (id)init { // to add a new node and initialize it 
mobInfo = [[NSMutableArray alloc] init]; 
MobRec *aNewMobRec = [[MobRec alloc] init]; 
[mobInfo addObject:aNewMobRec]; 
[aNewMobRec release]; 
} 

回答

3

的问题是,单独的文件在你的项目中没有其他文件的知识,因为Objective-C的是你需要#import,你需要使用的其他类的头文件C的衍生物,

// ModDef.m 
#import "MobDef.h" 
#import "ModRec.h" 

@implementation MobDef 

@synthesize mobInfo; // case matters here 

- (id)init 
{ 
    mobInfo = [[NSMutableArray alloc] init]; 
    MobRec* aNewMobRec = [[MobRec alloc] init]; 
    [mobInfo addObject:aNewMobRec]; 
    [aNewMobRec release]; 
} 

@end 
0

好了,你的@synthesize不符@property声明 - 你声明属性mobInfo但产生合成访问器MobInfo

你是否得到了一些其他的错误?

+0

这只是一个错误的帖子谢谢。 – user240272 2009-12-31 03:01:20