Tutorial: Convert NSArray to NSDictionary

Is very easy, you only have to use this method:

- (NSDictionary *) indexKeyedDictionaryFromArray:(NSArray *)array
{
id objectInstance;
NSUInteger indexKey = 0;
NSMutableDictionary *mutableDictionary = [[NSMutableDictionary alloc] init];
for (objectInstance in array)
[mutableDictionary setObject:objectInstance forKey:[NSNumber numberWithUnsignedInt:indexKey++]];
return (NSDictionary *)[mutableDictionary autorelease];
}
Tutorial: Convert NSArray to NSDictionary Tutorial: Convert NSArray to NSDictionary Reviewed by Unknown on 12:17 Rating: 5

No hay comentarios:

Con la tecnología de Blogger.