We Recommend

Programming in Objective-C Programming in Objective-C
Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming. The book makes no assumption about prior experience with object-oriented programming languages or with the C language (upon which Objective-C is based). And because of this, both novice and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C.


Posted By

0xced on 04/08/09


Tagged

png iphone uikit artwork


Versions (?)


Extract UIKit artwork


Published in: Objective C 


  1. #import <mach-o/dyld.h>
  2. #import <mach-o/nlist.h>
  3.  
  4. extern UIImage *_UIImageWithName(NSString *);
  5.  
  6. - (NSMutableDictionary*) UIKitImages
  7. {
  8. NSMutableDictionary *mappedImages = nil;
  9.  
  10. for(uint32_t i = 0; i < _dyld_image_count(); i++) {
  11. if (strstr(_dyld_get_image_name(i), "UIKit.framework")) {
  12. struct nlist symlist[] = {{"___mappedImages", 0, 0, 0, 0}, NULL};
  13. if (nlist(_dyld_get_image_name(i), symlist) == 0 && symlist[0].n_value != 0) {
  14. mappedImages = (NSMutableDictionary*)*(int*)symlist[0].n_value;
  15. }
  16. break;
  17. }
  18. }
  19.  
  20. return mappedImages;
  21. }
  22.  
  23. - (IBAction) extractArtwork:(id)sender
  24. {
  25. for (NSString *imageName in [[self UIKitImages] allKeys]) {
  26. NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
  27. NSString *imagePath = [documentsPath stringByAppendingPathComponent:imageName];
  28. [UIImagePNGRepresentation(_UIImageWithName(imageName)) writeToFile:imagePath atomically:YES];
  29. }
  30. }

Report this snippet 

You need to login to post a comment.