我有#define预处理器来定义IPAddress。我想从我的应用程序更改IPAddress,以便我可以与另一个IPAddress进行交互。我怎样才能实现这个目标
#define validateServerRequestURL @"http://192.168.1.85/"
答案 0 :(得分:1)
无法更改宏,但您可以通过将宏存储在NSString
中来处理它,然后您可以修改该字符串,即IPAddress
答案 1 :(得分:0)
我解决了它
public class ScrollerCustomDuration extends Scroller {
private double mScrollFactor = 1;
public ScrollerCustomDuration(Context context) {
super(context);
}
public ScrollerCustomDuration(Context context, Interpolator interpolator) {
super(context, interpolator);
}
@SuppressLint("NewApi")
public ScrollerCustomDuration(Context context, Interpolator interpolator, boolean flywheel) {
super(context, interpolator, flywheel);
}
/**
* Set the factor by which the duration will change
*/
public void setScrollDurationFactor(double scrollFactor) {
mScrollFactor = scrollFactor;
}
@Override
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
Log.e("##### FIX flash issue",""+startX);
Log.e("##### FIX flash issue",""+startY);
Log.e("##### FIX flash issue",""+dx);
Log.e("##### FIX flash issue",""+dy);
Log.e("##### FIX flash issue",""+duration);
super.startScroll(startX, startY, dx, dy, (int) (duration * mScrollFactor));
}
}
其中IPAddress和PortNumber是要保存在用户默认值中的其他宏
答案 2 :(得分:0)
只需提及字符串旁边的宏名称即可加入宏。
E.g。
#define IPAddress @"http://www.apple.com"
#define validateServerRequestURL @"http://192.168.1.85/"IPAddress
在运行时validateServerRequestURL
将是串联字符串http://192.168.1.85/http://www.apple.com