This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Tweak.xm

By: Libertasmens on Jul 29th, 2012  |  syntax: Objective C  |  size: 1.72 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #import <objc/runtime.h>
  2.  
  3. @implementation NSObject (InstanceVariableForKey)
  4. - (void *)instanceVariableForKey:(NSString *)aKey {
  5.     if (aKey) {
  6.         Ivar ivar = object_getInstanceVariable(self, [aKey UTF8String], NULL);
  7.         if (ivar) {
  8.             return (void *)((char *)self + ivar_getOffset(ivar));
  9.         }
  10.     }
  11.     return NULL;
  12. }
  13.  
  14. @end
  15.  
  16. typedef struct {
  17.     char itemIsEnabled[23];
  18.     char timeString[64];
  19.     int gsmSignalStrengthRaw;
  20.     int gsmSignalStrengthBars;
  21.     char serviceString[100];
  22.     char serviceCrossfadeString[100];
  23.     char serviceImages[3][100];
  24.     char operatorDirectory[1024];
  25.     unsigned int serviceContentType;
  26.     int wifiSignalStrengthRaw;
  27.     int wifiSignalStrengthBars;
  28.     unsigned int dataNetworkType;
  29.     int batteryCapacity;
  30.     unsigned int batteryState;
  31.     char notChargingString[150];
  32.     int bluetoothBatteryCapacity;
  33.     int thermalColor;
  34.     unsigned int thermalSunlightMode:1;
  35.     unsigned int slowActivity:1;
  36.     unsigned int syncActivity:1;
  37.     char activityDisplayId[256];
  38.     unsigned int bluetoothConnected:1;
  39.     unsigned int displayRawGSMSignal:1;
  40.     unsigned int displayRawWifiSignal:1;
  41. } SbStatusBarDataType;
  42.  
  43.  
  44.  
  45.  
  46. - (void *) instanceVariableForObject: (id)obj andKey: (NSString *)key {
  47.     if (key != nil) {
  48.         Ivar ivar = object_getInstanceVariable(obj, [key UTF8String], NULL);
  49.         if (ivar) {
  50.             return (void *)((char *)obj + ivar_getOffset(ivar));
  51.         }
  52.     }
  53.     return NULL;
  54. }
  55.  
  56. SBStatusBarDataManager* mgr = [SBStatusBarDataManager sharedDataManager];
  57. SbStatusBarDataType data = *(SbStatusBarDataType*)[self instanceVariableForObject: mgr andKey: @"_data"];
  58. int signalStrength = data.wifiSignalStrengthRaw;
clone this paste RAW Paste Data