【发布时间】:2011-11-18 11:21:21
【问题描述】:
我在一个对象中有一个 NSMutableArray。 在对象方法中,我会这样做:
/* ... */
[[LRResty client] get:connectURL withBlock:^(LRRestyResponse *r) {
SBJsonParser *jsonParser = [SBJsonParser new];
NSDictionary *jsonResponse = [jsonParser objectWithString:[r asString]];
NSDictionary *permittedBases= [jsonResponse objectForKey:@"permittedBases"];
Database *database = [[Database alloc] init];
for (id key in permittedBases) {
/* ... */
[workingDatabases addObject:database];
}
}];
return workingDatabases;
在返回行,我的数组中没有对象(不再)。我知道“数据库”对象超出范围这一事实。但我将它们保存在数组中。
我在监督什么吗?
如果有帮助,这里是头文件:
@class Database;
@interface CommunicationHelper : NSObject {
NSMutableArray *workingDatabases;
}
// The function where the problem appears:
- (NSMutableArray *)getDatabasesForWebsite:(Website *)websiteIn;
@property(nonatomic,copy) NSMutableArray *workingDatabases;
@end
【问题讨论】:
标签: objective-c arrays scope