Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <objc/runtime.h>
  2. #include <objc/message.h>
  3.  
  4. #include <CoreFoundation/CoreFoundation.h>
  5.  
  6. /* ... */
  7.  
  8. /**
  9. * Return a character string that holds the current version
  10. * of the operating system which is equivalent to:
  11. * `[[UIDevice currentDevice] systemVersion]`
  12. * in plain Obj-C code.
  13. * The caller must manage deletion.
  14. */
  15. char *getsystemversion(void) {
  16. char *sv = NULL;
  17. id Dev = objc_msgSend(objc_getClass("UIDevice"), sel_getUid("currentDevice"));
  18. CFStringRef SysVer = (CFStringRef) objc_msgSend(Dev, sel_getUid("systemVersion"));
  19. CFIndex len = CFStringGetLength(SysVer);
  20. CFIndex max = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8);
  21. sv = (char *) malloc(max + 1);
  22. CFStringGetCString(SysVer, sv, max, kCFStringEncodingUTF8);
  23. return sv;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement