def responseHandlerBlock(self, _cmd, data, response, error): if error is not None: self.error = objc_util.ObjCInstance(error) else: response = objc_util.ObjCInstance(response) data = objc_util.ObjCInstance(data) self.data = objc_util.nsdata_to_bytes(data)
def objc_to_str(objc, pretty=True): if checkObject(objc): return nsdata_to_bytes( NSJSONSerialization.dataWithJSONObject_options_error_( objc, int(pretty), None)).decode('utf-8') else: raise TypeError("Objc object can't be converted") return None
def responseHandlerBlock(self, _cmd, data, response, error): if error is not None: error = objc_util.ObjCInstance(error) print(error) return response = objc_util.ObjCInstance(response) data = objc_util.ObjCInstance(data) self.data = (str(objc_util.nsdata_to_bytes(data)))
def nowplaying(self): if self._nowplaying.ptr: b = nsdata_to_bytes(self._nowplaying.plistData()) data = loads(b) # striping the prefix from items for i in data: data[i.replace('kMRMediaRemoteNowPlayingInfo', '')] = data.pop(i) return data else: return None
def nowplaying(self): if self._nowplaying.ptr: global data b = nsdata_to_bytes(self._nowplaying.plistData()) data = loads(b) # striping the prefix from items #print(data.keys()) filtered = {} for i in data: filtered[i.replace('kMRMediaRemoteNowPlayingInfo', '')] = data[i] return filtered else: return None
def nsDicToPyDic(nsDic): pyDic = {} for k in nsDic.allKeys(): v = nsDic[k] if v.isKindOfClass_(NSString): v = str(v) elif v.isKindOfClass_(NSBoolean): v = bool(v) elif v.isKindOfClass_(NSNumber): vs = v.stringValue() if vs.rangeOfString_(ns(".")).length > 0: v = float(str(vs)) else: v = v.intValue() elif v.isKindOfClass_(NSData): v = nsdata_to_bytes(v) elif v.isKindOfClass_(NSDictionary): v = nsDicToPyDic(v) pyDic[str(k)] = v return pyDic
def _endContext(self): image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() png = UIImagePNGRepresentation(image) data = objc_util.nsdata_to_bytes(png) return data
def objc_to_str(objc, pretty=True): if checkObject(objc): return nsdata_to_bytes(NSJSONSerialization.dataWithJSONObject_options_error_(objc, int(pretty), None)).decode('utf-8') else: raise TypeError("Objc object can't be converted") return None