Guest User

Untitled

a guest
Jul 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. - (NSString *)machine
  2. {
  3. static NSString *machine = nil;
  4.  
  5. // we keep name around (its like 10 bytes....) forever to stop lots of little mallocs;
  6. if(machine == nil)
  7. {
  8. char * name = nil;
  9. size_t size;
  10.  
  11. // Set 'oldp' parameter to NULL to get the size of the data
  12. // returned so we can allocate appropriate amount of space
  13. sysctlbyname("hw.machine", NULL, &size, NULL, 0);
  14.  
  15. // Allocate the space to store name
  16. name = malloc(size);
  17.  
  18. // Get the platform name
  19. sysctlbyname("hw.machine", name, &size, NULL, 0);
  20.  
  21. // Place name into a string
  22. machine = [[NSString stringWithUTF8String:name] retain];
  23. // Done with this
  24. free(name);
  25. }
  26.  
  27. return machine;
  28. }
  29.  
  30. -(BOOL)hasVibration
  31. {
  32. NSString * machine = [self machine];
  33.  
  34. if([[machine uppercaseString] rangeOfString:@"IPHONE"].location != NSNotFound)
  35. {
  36. return YES;
  37. }
  38.  
  39. return NO;
  40. }
  41.  
  42. AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
  43.  
  44. AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
Add Comment
Please, Sign In to add comment