我有这样的HTML:
<div class="container">
<span class="iconset"></span> <!-- want to select -->
<span class="iconset"></span>
</div>
<div class="container">
<span class="iconset"></span> <!-- want to select -->
<span class="iconset"></span>
</div>
Run Code Online (Sandbox Code Playgroud)
我需要选择每个元素的第一个元素.container,使用:
$(".container .iconset:first");
Run Code Online (Sandbox Code Playgroud)
我只得到一个元素,第一个找到.并使用
$(".container .iconset");
Run Code Online (Sandbox Code Playgroud)
我得到了所有4个元素.我不想检查偶数或奇数的索引,因为稍后可以添加更多元素.
如何构建一个选择器来返回每个容器上的所有第一个元素?
正如标题所说:为什么string.Join需要采用数组而不是IEnumerable?这让我很烦,因为当我需要从LINQ表达式的结果创建一个连接字符串时,我必须添加一个.ToArray().
我的经验告诉我,我在这里遗漏了一些明显的东西.
我需要能够同时拥有AVCaptureVideoDataOutput和AVCaptureMovieFileOutput工作.以下代码有效,但视频录制没有.在didFinishRecordingToOutputFileAtURL直接后调用委托startRecordingToOutputFileURL被调用.现在,如果我AVCaptureVideoDataOutput从
AVCaptureSession简单的评论中删除该行:
[captureSession addOutput:captureDataOutput];
视频录制工作,但然后不调用SampleBufferDelegate(我需要).
我怎样才能兼顾AVCaptureVideoDataOutput并AVCaptureMovieFileOutput同时工作.
- (void)initCapture {
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:NULL];
captureDataOutput = [[AVCaptureVideoDataOutput alloc] init];
[captureDataOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init];
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[captureDataOutput setVideoSettings:videoSettings];
captureSession = [[AVCaptureSession alloc] init];
[captureSession addInput:captureInput];
[captureSession addOutput:m_captureFileOutput];
[captureSession addOutput:captureDataOutput];
[captureSession beginConfiguration];
[captureSession setSessionPreset:AVCaptureSessionPresetLow];
[captureSession commitConfiguration];
[self performSelector:@selector(startRecording) …Run Code Online (Sandbox Code Playgroud) 我正在考虑是否有两个指针更好,每个对象子类和超级一个,或者我是否应该使用强制转换.
这使用了多少系统资源:
objectName.functionOne();
((SubClass) objectName).functionOther();
Run Code Online (Sandbox Code Playgroud)
它比以下更好:
SuperClass objectA = (SuperClass) getSameInstance();
SubClass objectB = getSameInstance();
objectA.functionOne();
objectB.functionOther();
Run Code Online (Sandbox Code Playgroud)
基本上,我的主要问题是关于铸造使用的资源,而不是制作额外的指针.看起来我可以保存几个在线演员阵容,例如:
((SubClass) objectName).functionOther();
Run Code Online (Sandbox Code Playgroud)
但是,值得吗?
谢谢,
格雷
我的问题有一些不清楚的部分.基本上,我有一个超级类,我通过一个大功能使用.它适用于三个子类.有些超级班级正在按照我的意愿行事.但是,我在一些地方碰到了路障,我必须使用三个不同子类中的一个来完成一个功能; 仅在其中一个子类中的函数.
我可能只有:
SuperClass instanceRef;
SubClass instanceRef2;
instanceRef.etc()
instanceRef.etc2()
instanceRef.etc3()
instanceRef2.specialSubClassOnlyCall();
instanceRef2.specialSubClassOnlyCall2();
Run Code Online (Sandbox Code Playgroud)
或者我可以:
SuperClass instanceRef;
instanceRef.etc()
instanceRef.etc2()
instanceRef.etc3()
((SpecialSubClass)instanceRef).specialSubClassOnlyCall();
((SpecialSubClass)instanceRef).specialSubClassOnlyCall2();
Run Code Online (Sandbox Code Playgroud)
但是,我不知道哪个更有效率.
这是一个例子,向您展示我在说什么:
class Shape
Triangle extends Shape
Square extends Shape
Circle extends Shape
Cube extends Shape
Run Code Online (Sandbox Code Playgroud)
两个指针示例:(缩小额外指针.)
Shape pointer1 = (Shape) getSomeRandomShape();
Cube pointer2 = null;
pointer1.getWidth();
pointer1.getHeight();
pointer1.generalShapeProp();
pointer1.generalShapeProp2();
pointer1.generalShapeProp3();
if(sure_its_cube)
{
pointer2 = …Run Code Online (Sandbox Code Playgroud) 如果我在构建配置中添加了用户定义的设置,我如何在Objective-C代码中读取该设置?
我的项目中有两个文件,debug.plist并且release.plist.我希望我MainApp.m的文件根据正在运行的构建配置读取其中一个文件.我在Debug和Release配置中设置了一个名为"filename"的用户定义设置,指向相应的文件.但我不知道我的MainApp.m文件如何从当前运行的配置中读取filename变量.
我想做的事:
编写一个监听Office事件的应用程序。我想从计算机上打开的任何实例中监听事件。例如,如果我在Word中收听BeforeDocumentSave,那么只要主机上任何Word实例保存文档,我都希望激活此方法的接收器。
另一个要求是,我要用C ++编写而不使用MFC或ATL。
我所做的:
我已经编写了一个程序来监听Word事件。请参见下面的代码。
问题:
它不起作用-尽管我打开了Word应用程序并执行了应触发事件的操作,但从未输入事件处理程序。
我有一些具体的问题,当然,任何其他意见都将受到欢迎!
问题:
是否可以侦听不是由我启动的应用程序中的事件?在我发现的所有示例中,侦听应用程序都会启动要侦听的Office应用程序。
在Microsoft howto(http://support.microsoft.com/kb/183599/EN-US/)中,我发现以下注释:
但是,大多数事件(例如Microsoft Excel的Workbook事件)并非以DISPID 1开头。在这种情况下,必须在MyEventSink.cpp中显式修改分派映射,以使DISPID与正确的方法匹配。
如何修改调度图?
码:
这是我的项目的头文件,后跟C文件:
#ifndef _OFFICEEVENTHANDLER_H_
#define _OFFICEEVENTHANDLER_H_
// 000209FE-0000-0000-C000-000000000046
static const GUID IID_IApplicationEvents2 =
{0x000209FE,0x0000,0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
struct IApplicationEvents2 : public IDispatch // Pretty much copied from typelib
{
/*
* IDispatch methods
*/
STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj) = 0;
STDMETHODIMP_(ULONG) AddRef() = 0;
STDMETHODIMP_(ULONG) Release() = 0;
STDMETHODIMP GetTypeInfoCount(UINT *iTInfo) = 0;
STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) = 0; …Run Code Online (Sandbox Code Playgroud) 我在某处读过当前的机器模型不太适合函数式编程.那么当前机器模型的局限性是什么?有没有更合适的机型开发?
操作系统的核心(设备交互级别)是用C语言编写的,还是"用C语言编写"意味着只有大部分操作系统是用C语言编写的,与设备的交互是用asm编写的?
为什么我这样问:
好.那我到底怎么样?我无法想象如何与控制器硬盘或USB控制器或其他一些我们应该发送信号的实际内容进行交互而不用(或少量)asm.毕竟,谢谢.我将看看其他一些网络来源.
PS(洪水)很可惜我们在大学没有操作系统课程,尽管MIPT是麻省理工学院的俄罗斯双胞胎,我发现没人在这里写像minix这样的操作系统.
我想知道是否有一种方法可以在SQL Server表创建后在特定位置添加一个列?
谢谢.
C++不能保证在输入失败时保持变量不变吗?对于旧版本的gcc,像这样的程序会将i的-1值保持为失败(例如,如果输入的是字母而不是输入的数字).使用Ubuntu 10.10(gcc 4.4.5)时,如果输入失败,i将重置为零.
#include <iostream>
int main()
{
int i = -1;
std::cin >> i;
std::cout << "i = " << i << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这种行为打破了我的很多代码.我想gcc的人都知道他们在做什么,这很可能是我的错.如果有人知道这个标准,我想知道它对这种情况的看法.
谢谢.