def _copy(target, preferredFilename, noOpen): target = '(' + target + ')' if objectHelpers.isKindOfClass(target, 'NSURL'): _copyFromURL(target, preferredFilename, noOpen) elif objectHelpers.isKindOfClass(target, 'NSData'): _copyFromData( target, time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime()) + ".data", preferredFilename, noOpen) else: print('{} isn\'t supported. You can copy an NSURL or NSData.'.format( objectHelpers.className(target)))
def _copy(target, preferredFilename, noOpen): target = "(" + target + ")" if objectHelpers.isKindOfClass(target, "NSURL"): _copyFromURL(target, preferredFilename, noOpen) elif objectHelpers.isKindOfClass(target, "NSData"): _copyFromData( target, time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime()) + ".data", preferredFilename, noOpen, ) else: print("{} isn't supported. You can copy an NSURL or NSData.".format( objectHelpers.className(target)))
def _showColor(color): color = "(" + color + ")" colorToUse = color isCF = _colorIsCGColorRef(color) if isCF: colorToUse = "[[UIColor alloc] initWithCGColor:(CGColorRef){}]".format( color) else: isCI = objectHelpers.isKindOfClass(color, "CIColor") if isCI: colorToUse = "[UIColor colorWithCIColor:(CIColor *){}]".format( color) imageSize = 58 fb.evaluateEffect( "UIGraphicsBeginImageContextWithOptions((CGSize)CGSizeMake({imageSize}, {imageSize}), NO, 0.0)" .format(imageSize=imageSize)) fb.evaluateEffect("[(id){} setFill]".format(colorToUse)) fb.evaluateEffect( "UIRectFill((CGRect)CGRectMake(0.0, 0.0, {imageSize}, {imageSize}))". format(imageSize=imageSize)) result = fb.evaluateExpressionValue( "(UIImage *)UIGraphicsGetImageFromCurrentImageContext()") if result.GetError() is not None and str(result.GetError()) != "success": print("got error {}".format(result)) print(result.GetError()) else: image = result.GetValue() _showImage(image) fb.evaluateEffect("UIGraphicsEndImageContext()")
def _visualize(target): target = fb.evaluateInputExpression(target) if fb.evaluateBooleanExpression("(unsigned long)CFGetTypeID((CFTypeRef)" + target + ") == (unsigned long)CGImageGetTypeID()"): _showImage("(id)[UIImage imageWithCGImage:" + target + "]") else: if objectHelpers.isKindOfClass(target, "UIImage"): _showImage(target) elif objectHelpers.isKindOfClass(target, "UIView"): _showLayer("[(id)" + target + " layer]") elif objectHelpers.isKindOfClass(target, "CALayer"): _showLayer(target) elif (objectHelpers.isKindOfClass(target, "UIColor") or objectHelpers.isKindOfClass(target, "CIColor") or _colorIsCGColorRef(target)): _showColor(target) elif objectHelpers.isKindOfClass(target, "NSData"): if _dataIsImage(target): _showImage("(id)[UIImage imageWithData:" + target + "]") elif _dataIsString(target): print( fb.describeObject("[[NSString alloc] initWithData:" + target + " encoding:4]")) else: print("Data isn't an image and isn't a string.") else: print( "{} isn't supported. You can visualize UIImage, CGImageRef, UIView, CALayer, NSData, UIColor, CIColor, or CGColorRef." .format(objectHelpers.className(target)))