Util.m
上传用户:xy800802
上传日期:2020-12-29
资源大小:194k
文件大小:1k
源码类别:

iPhone

开发平台:

Objective-C

  1. #import "Util.h"
  2. @implementation Util
  3. +(void)SetBadge:(NSString*)badgeText
  4. {
  5. if(badgeText!=nil)
  6. {
  7. [ UIApp setApplicationBadge: badgeText ];
  8. }
  9. }
  10. +(void)RemoveBadge
  11. {
  12. [ UIApp removeApplicationBadge ];
  13. }
  14. +(int)RestartSpringboard
  15. {
  16. pid_t child = fork();
  17. if(child == 0){
  18. execlp("/bin/launchctl","launchctl","stop","com.apple.SpringBoard",NULL);
  19. sleep(1);
  20. exit(1);
  21. }
  22. return 0;
  23. }
  24. +(int)GetRandNum
  25. {
  26. srand(time(0));
  27. return rand();
  28. }
  29. +(NSString*)GetNSString:(char *)cstring
  30. {
  31.     return [[NSString alloc] initWithCString:cstring];
  32. }
  33. @end