我Property 'aVariable' not found on object of type id在尝试读取或写入数组的变量时得到了.不应该知道我添加的对象是什么类?还注意到它用于读取值NSLog(@" %@",[[anArray objectAtIndex:0] aVariable]);
我是Objective C的初学者,所以我可能会遇到一些简单的事情.
@interface AnObject : NSObject
@property (nonatomic,readwrite) int aVariable;
@end
Run Code Online (Sandbox Code Playgroud)
@interface AnotherObject : NSObject
@end
Run Code Online (Sandbox Code Playgroud)
#import "test.h"
@implementation AnObject
@synthesize aVariable;
- (id)init
{
self = [super init];
if (self) {
aVariable=0;
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
@implementation AnotherObject
- (id)init
{
self = [super init];
if (self) { }
return self;
}
- (NSMutableArray*) addToArray
{
NSMutableArray* anArray = …Run Code Online (Sandbox Code Playgroud)