目前,我使用的是有符号值,-2 ^ 63到2 ^ 63-1.现在我需要相同的范围(2*2 ^ 64),但只有正值.我发现java文档提到unsigned long,它适合这种用法.
我试图将2 ^ 64声明为一个Long包装器对象,但它仍然丢失了数据,换句话说,它只捕获到了Long.MAX_VALUE,所以我显然遗漏了一些东西.是BigInteger的签署久,Java支持?
是否有关于如何声明和使用它的定义或指针?
我想以编程方式创建一个新的NSWindow,但我找不到成功的方法.这个简单的代码不会显示新窗口.它出什么问题了?
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
let win = NSWindow(contentRect: NSMakeRect(100, 100, 600, 200),
styleMask: NSResizableWindowMask,
backing: NSBackingStoreType.Buffered, defer: true)
let controller = NSWindowController(window: win)
controller.showWindow(self)
win.makeKeyAndOrderFront(win)
}
}
Run Code Online (Sandbox Code Playgroud) 我想首先应用CSS但是:first-child适用于每个ul的所有第一个孩子
这是我的CODE
#menu-navigation li:first-child{
color:red;
}?
Run Code Online (Sandbox Code Playgroud)
应用于此HTML时:
<ul class="nav" id="menu-navigation">
<li>Home</li>
<li>About Us
<ul>
<li>Our Team</li>
</ul>
</li>
</ul>?
Run Code Online (Sandbox Code Playgroud)
......"Home"和"Our Team"都变红了.
我收到了一个错误报告,其中堆栈跟踪的顶部类似于:
System.NullReferenceException: <...> at MyApplication.MyType.SomeMethod(String arg) in MyType.cs:line 0Run Code Online (Sandbox Code Playgroud)
关键是,行号是0。什么会导致这种堆栈跟踪行为?
我目前在iOS应用程序中使用本地存储.用户数据存储在文档目录中,现在我计划使用iCloud Documents存储.
这是我打算如何做到的:
检查设备上是否有iCloud可用
如果是,请使用URLForUbiquityContainerIdentifier获取iCloud容器URL
将新文件和文档保存到此新URL
为此,我使用此代码将返回文档文件夹的URL(iCloud或本地)
class CloudDataManager {
class func getDocumentDiretoryURL() -> NSURL {
let localDocumentsURL = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: .UserDomainMask).last! as NSURL
let iCloudDocumentsURL = NSFileManager.defaultManager().URLForUbiquityContainerIdentifier(nil)?.URLByAppendingPathComponent("Documents")
if userDefault.boolForKey("useCloud") && iCloudDocumentsURL != nil {
return iCloudDocumentsURL!
} else {
return localDocumentsURL
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是最好的做法吗?如果有一天iCloud不可用,我担心会出现问题,因此将使用本地目录而不是云容器,并且将为空.谢谢.
我正在尝试使用FileManager's 将一些(媒体)文件从一个文件夹复制到另一个文件夹copyItem(at:path:),但我收到错误:
CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL错误Domain = NSCocoaErrorDomain Code = 262"由于不支持指定的URL类型,因此无法打开该文件."
我正在使用Xcode 9 beta和Swift 4.
let fileManager = FileManager.default
let allowedMediaFiles = ["mp4", "avi"]
func isMediaFile(_ file: URL) -> Bool {
return allowedMediaFiles.contains(file.pathExtension)
}
func getMediaFiles(from folder: URL) -> [URL] {
guard let enumerator = fileManager.enumerator(at: folder, includingPropertiesForKeys: []) else { return [] }
return enumerator.allObjects
.flatMap {$0 as? URL}
.filter { $0.lastPathComponent.first != "." && isMediaFile($0)
}
}
func move(files: [URL], to location: URL) {
do {
for …Run Code Online (Sandbox Code Playgroud) 我正在制作一个录音应用程序.在app中我有一个Seekbar来改变输入语音增益.我找不到任何调整输入语音增益的方法.
我正在使用AudioRecord类来录制语音.
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
RECORDER_SAMPLERATE, RECORDER_CHANNELS,
RECORDER_AUDIO_ENCODING, bufferSize);
recorder.startRecording();
Run Code Online (Sandbox Code Playgroud)
我在Play商店看到了一个使用此功能的应用程序.
https://play.google.com/store/apps/details?id=com.grace.microphone
我写了一个名为的课Queue.当我尝试构建项目时,出现编译时错误.
该.h文件中:
template<class Queue_entry>
class MyQueue {
public:
MyQueue();
bool empty() const;
// add entry in the tail of the queue
Error_code append(Queue_entry &x);
// throw the entry of the front
Error_code serve();
// get the front entry of the queue
Error_code retrieve(Queue_entry &x) const;
protected:
Queue_entry entry[MAXQUEUE];
int count;
int front, rear;
};
Run Code Online (Sandbox Code Playgroud)
看来.cpp文件中有错误:
MyQueue.cpp:17:1:'MyQueue'不是类,命名空间或枚举
我不知道什么是错的,但是当我将模板更改为时
#define Queue_entry int
Run Code Online (Sandbox Code Playgroud)
它可以成功运行.
为什么我在最后两行收到错误?目标是在集合中找到对象,并修改其内容。
using namespace std;
struct mystruct {
int id;
vector<int> y;
mystruct(const int id):id(id) {}
bool operator<(const mystruct& x) const { return id < x.id; }
bool operator==(const mystruct& x) const { return id == x.id; }
};
void test() {
std::set<mystruct> sx;
mystruct x(1);
x.y.push_back(1); x.y.push_back(2);
sx.insert(x);
//
set<mystruct>::iterator i = sx.find(1);
const mystruct* x1 = &(*i);
const mystruct x2 = *x1;
cout << &(i->y) << endl;
cout << &(x1->y) << endl;
cout << x2.id << endl;
x2.y.push_back(3);
i->y.push_back(4); …Run Code Online (Sandbox Code Playgroud) 这只是未注释代码的一小部分.打包向量一直导致错误push_back(),我不太清楚为什么:
编辑:它已更新说
vector<BinTreeNode<HuffmanToken<Pixel>* > > packing = new vector<BinTreeNode<HuffmanToken<Pixel> > >();
Run Code Online (Sandbox Code Playgroud)
但是,即使使用调整后的模板,仍然存在分配器错误.
没有匹配的函数来调用std :: vector,std :: allocator >> :: push_back(BinTreeNode >> &&
BinTree<HuffmanToken<Pixel> >* Huffman::buildTree(const vector<HuffmanToken<Pixel>>& tokens) {
BinTreeNode<HuffmanToken<Pixel> >* g1 = new BinTreeNode<HuffmanToken<Pixel> >();
BinTreeNode<HuffmanToken<Pixel> >* g2 = new BinTreeNode<HuffmanToken<Pixel> >();
BinTreeNode<HuffmanToken<Pixel> >* g3 = new BinTreeNode<HuffmanToken<Pixel> >();
vector<HuffmanToken<Pixel> > packing ;
vector<HuffmanToken<Pixel> >::const_iterator it;
it = tokens.begin();
for(int i = 0; i < tokens.size(); i++) {
g1 -> setValue(tokens.at(i));
packing.push_back(g1);
}
Run Code Online (Sandbox Code Playgroud) c++ ×3
swift ×3
java ×2
vector ×2
.net ×1
android ×1
audiorecord ×1
biginteger ×1
c# ×1
css ×1
html ×1
icloud ×1
ios ×1
long-integer ×1
macos ×1
macos-sierra ×1
nswindow ×1
push-back ×1
set ×1
stack-trace ×1
stl ×1
struct ×1
swift3 ×1
unsigned ×1
xcode ×1
xcode9-beta ×1