Fast enumeration & fix self-checking in initForType:.

This commit is contained in:
Nate Weaver 2012-07-06 09:48:44 -05:00
parent 0fbb82af18
commit 559e3fa755

View File

@ -13,13 +13,12 @@
- (id)initForType:(NSString *)typeString
{
self = [super init];
type = [typeString copy];
data = [[NSMutableDictionary alloc] init];
{
id <ResKnifeResourceProtocol> resource;
if (self) {
type = [typeString copy];
data = [[NSMutableDictionary alloc] init];
NSArray *resources = [NSClassFromString(@"Resource") allResourcesOfType:type inDocument:nil]; // nil document will search in ANY open document for the correct resource
NSEnumerator *enumerator = [resources objectEnumerator];
while( resource = [enumerator nextObject] )
while( id <ResKnifeResourceProtocol> resource in resources )
[data setObject:[resource name] forKey:[resource resID]];
}
parsed = [[NSMutableArray alloc] initWithArray:[data allValues]];