我想完成触摸 a UIButton并让代码在与所有者不同的类中运行.
我意识到我可以touchUpInside对按钮的所有者(ClassA)执行操作,然后调用ClassB我想调用的方法,但有没有办法加快这个?
思路:
有ClassB是为委托ClassA->UIButton
touchUpInside在编程中设置调用以使用内部函数ClassB
我不知道如何完成以下任何一个想法:(输入是mas赞赏!
什么是差异,优点或缺点
var obj = {};
Run Code Online (Sandbox Code Playgroud)
VS
var obj = new Object();
Run Code Online (Sandbox Code Playgroud)
我所知道的是第二个例子需要更长的时间.有什么真正的好处吗?
**编辑**
function loop() {
var start = (new Date()).getTime();
for(var i = 0; i < 1000000; ++i) {
//var b = {}; // takes ~548ms on my machine
var b = new Object(); // takes ~287ms on my machine
}
trace((new Date()).getTime() - start);
setTimeout(loop, 1);
}
loop();
Run Code Online (Sandbox Code Playgroud)
如果你在之间切换var b = {};,var b = new Object();你会看到性能差异.他们与我的回忆以及我在问题中提到的内容相反.
文字示例:
1
00:00:00,000 --> 00:00:01,000
This is the first line
2
00:00:01,000 --> 00:00:02,000
This is the second line
3
00:00:02,000 --> 00:00:03,000
This is the last line
Run Code Online (Sandbox Code Playgroud)
在JavaScript中,我会用正则表达式解析它.我只是想知道,这是在Obj C中做到这一点的最好方法吗?我确信我可以找到一种方法来做到这一点,但我想以适当的方式做到这一点.
我只需要知道从哪里开始,我很乐意做其余的事情,但为了理解我最终会得到这样的东西(伪代码):
NSDictionary
index -> [0-9]+
start -> hh:mm:ss,mmm
end -> hh:mm:ss,mmm
text -> one of the lines of text
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我将在我的字典中解析三个条目.
让我说我有
var myCanvas = document.createElement('canvas');
Run Code Online (Sandbox Code Playgroud)
而我呢
myCanvas.setAttribute("id", "my-canvas");
document.body.appendChild(myCanvas);
Run Code Online (Sandbox Code Playgroud)
后来我改变了myCanvas并希望用我更新的画布替换 html- DOMcanvas.以下作品:
document.getElementById("my-canvas").innerHTML = myCanvas;
Run Code Online (Sandbox Code Playgroud)
但是html(通过检查员)看起来像
<canvas id="my-canvas">[object HTMLCanvasElement]</canvas>
Run Code Online (Sandbox Code Playgroud)
什么时候看起来像
<canvas id="my-canvas"></canvas>
Run Code Online (Sandbox Code Playgroud)
如何更新元素而不使用innerHTML?
我怀疑一些代码试图使用我的FooterArchiveView类似于一个NSDictionary所以我尝试使用断点来找到瓶颈,但我的断点正在向我发送一个疯狂的追逐系统文件,如UINibDecoderDecodeObjectForValue.我该怎么办?
2012-03-08 08:35:55.417 JOM App[44161:207] Uncaught exception: [<FooterArchiveView 0x9b27770> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key featured.
2012-03-08 08:35:55.420 JOM App[44161:207] Stack trace: (
0 CoreFoundation 0x0169c06e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x01c50d0a objc_exception_throw + 44
2 CoreFoundation 0x0169bf11 -[NSException raise] + 17
3 Foundation 0x00f89032 -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x00efaf7b _NSSetUsingKeyValueSetter + 136
5 Foundation 0x00efaeeb -[NSObject(NSKeyValueCoding) setValue:forKey:] + 287
6 UIKit 0x00628268 -[UIView(CALayerDelegate) setValue:forKey:] + 168 …Run Code Online (Sandbox Code Playgroud) 这只发生在IE中.
我正在使用swfobject并加载flash变量
var flashVars = {
myVar:'{"url":"http://google.com/", "id":"9999"}',
};
var params = {
allowFullScreen:"true",
wmode:"transparent",
allowScriptAccess:'always'
};
swfobject.embedSWF("mySwf.swf", "mySwf", "512", "318", "10.0.0", "./js/swfobject/expressInstall.swf", flashVars, params);
Run Code Online (Sandbox Code Playgroud)
一切都在IE浏览器中完美运行.我查了一下myVar,它进入了瑞士法郎{,就是这样.我知道它正在死亡'.我试过放一个前面\,然后尝试\\并继续添加一个斜线直到我到达\\\\\\\\.我甚至颠倒了所有斜线并尝试了同样的仪式.没有.
我可以通过反向引号和使用双斜杠来获取字符串,但是然后我的JSON解析器因为我的字符串中存在斜杠而生气.
这是一个有效的例子,但是什么是无效的JSON:
"{\\'url\\':\\'http://google.com/\\', \\'id\\':\\'9999\\'}"
Run Code Online (Sandbox Code Playgroud) 在我的代码中,我正在做:
[anNsDataObject writeToFile:@"thefile" atomically:YES];
Run Code Online (Sandbox Code Playgroud)
如何从设备中删除此文件?
我有
NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] init];
id dict = [myDictionary copy];
Run Code Online (Sandbox Code Playgroud)
但dict现在只是一个常规NSDictionary?或者是它的副本NSMutableDictionary?
另外,有没有办法从可变变为不可变?
我试图让div看起来像是从它的位置增长.为此,我将位置从相对位置更改为固定位置,这使得第一次转换从而top:0, left:0不是元素的当前顶部/左侧开始.如何修复此问题以使用元素当前偏移量?
注意:第一次单击后,代码完全符合我的要求.第一次点击就是问题所在.
当我运行我的JavaScript代码.我收到以下错误"Uncaught ReferenceError:THREE is not defined".提到的路线是:
var renderer = new THREE.WebGLRenderer();
// I have attached the three.js library in the script tag. I don't know what seems to be problem.
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth/window.innerHeight, 0.1, 1000);
camera.position.set = (0, 0, 10);
camera.lookAt(camera.position);
scene.add(camera);
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0.0, 1.0, 0.0));
geometry.vertices.push(new THREE.Vector3(-1.0, -1.0, 0.0));
geometry.vertices.push(new THREE.Vector3(1.0, -1.0, 0.0));
geometry.faces.push(new THREE.Face3(0, 1, 2));
var material = new THREE.BasicMeshMaterial({
color: 0xFFFFFF,
side: THREE.DoubleSide
}); …Run Code Online (Sandbox Code Playgroud) ios ×3
objective-c ×3
javascript ×2
nsdictionary ×2
cocoa ×1
copy ×1
css ×1
css-position ×1
css3 ×1
flashvars ×1
html5-canvas ×1
innerhtml ×1
json ×1
nsdata ×1
parsing ×1
string ×1
three.js ×1
writetofile ×1