n(.exe) and get the software.nThere are no updates to this program.n//
// UIImage+Compression.h
// GDLKit
//
// Created by QuintGao on 2017/3/25.
// Copyright © 2017年 高级程序包. All rights reserved.
#import
@interface UIImage (Compression)
/**
* @brief 压缩图片
* @param saveToFile saveToFile 自定义存储位置
* @param imageInputImage inputImage 输入图片
* @return 已压缩图片
*/
+ (UIImage *)GDL_compressImage:(UIImage *)image saveToFile:(NSString *)saveToFile imageInputImage:(UIImage *)image;
@end
Q:
How to pass a value to an object constructor with ampersand?
I have an object that has a constructor like:
var myObj = new Class();
Is there any way to pass a string to the constructor?
myObj = "myString"
I tried:
myObj = new Class(myString);
And,
myObj = new Class({myString});
but I am still getting an error saying:
Cannot set property'myString' of undefined
Any ideas?
A:
No, you cannot do this directly. The new Class(string) is an object literal with properties referring to the functions Class and new, and Class(object) is actually invoking those functions. See this page for the details. The value of the string is ignored, except for the Class(string) call, which will turn the string into a new object with Class.
If you want to assign the string "myString" to an instance property named myString, you can do it like this:
var obj = new Class();
obj.myString = "myString";
This is explained in the documentation for the prototype property. The full prototype chain is described here, but in your case you're just interested in the constructor property.
You could also do:
Related links:
댓글