我现在拥有的是
类A.h
@interface ClassA: NSObject <DelegateA>
-(id)initWithData:(NSData*)data;
+(Stores*)makeClass:(Class) name fromData:(NSData*)data;
@property (assign) NSMutableArray *arr;
@property (assign) RXMLElement *rxmlRoot;
@end
班A.m
-(id)initWithData:(NSData*)data {
self = [super init];
if (self) {
arr = [[NSMutableArray array] retain];
rxmlRoot = [[RXMLElement elementFromXMLData:data] retain];
}
[rxmlRoot iterate:node with:^(RXMLElement *e){ <--------get warning at here
NSLog(@"element is %@",e.tag);
Detail *detail = [[[Detail alloc] init] autorelease];
[detail setLat: [e attribute:@"lat"]];
[detail setLon: [e attribute:@"lon"]];
[arr addObject:detail];
}];
return self;
}
+(classA*)makeClass:(Class) name fromData:(NSData*)data{
ClassA *classA = [[ClassA alloc] initWithData:data];
return [storeClass autorelease] ;
}
和 RaptureXML.m
+ (id)elementFromXMLData:(NSData *)data {
return [[[RXMLElement alloc] initFromXMLData:data] autorelease];
}
- (id)initFromXMLData:(NSData *)data {
if ((self = [super init])) {
xml_ = [[TBXML alloc] initWithXMLData:data];
tbxmlElement_ = xml_.rootXMLElement;
}
return self;
}
警告:实例变量访问(通过'self')导致空指针取消引用
问题:为什么我收到此警告以及如何解决此问题。请就此给我建议。谢谢