Have you tried to inject a category into NSKeyedUnarchiver and catch the keys this way? Quick implementation and research, and you will find that the key is "UIResourceName". However, keep in mind that keyarch unarchiver returns only objects for the key in the current decoding area. This means that you cannot request this key from the root, and you need to delve deeply into the hierarchy of objects.
Below is the code that registers any related resources. It is up to you how you use it. It is also registered when the UIImage is decoded. You can return your own class if you want.
@interface NSKeyedUnarchiver (MyKeyedUnarchiver) @end @implementation NSKeyedUnarchiver (MyKeyedUnarchiver) - (id) mydecodeObjectForKey:(NSString *)key { id obj = [self mydecodeObjectForKey:key]; if ( [key isEqualToString:@"UIResourceName"] ) NSLog(@"The linked resource name is: %@", obj); return obj; } - (Class) myclassForClassName:(NSString *)codedName { if ( [codedName isEqualToString:@"UIImageNibPlaceholder"] ) NSLog(@"Decoding a UIImage"); return [self myclassForClassName:codedName]; } + (void) load { SEL origM = @selector( decodeObjectForKey: ); SEL newM = @selector( mydecodeObjectForKey: ); method_exchangeImplementations( class_getInstanceMethod( self, origM ), class_getInstanceMethod( self, newM ) ); origM = @selector( classForClassName: ); newM = @selector( myclassForClassName: ); method_exchangeImplementations( class_getInstanceMethod( self, origM ), class_getInstanceMethod( self, newM ) ); } @end
Hope this helps.
Szabi tolnai
source share