我正在尝试使用JNI和JDK 9.我有一个类NativeTest.java看起来像这样的类:
public class NativeTest {
static {
System.loadLibrary("hello");
}
private native void sayHello();
public static void main(String[] args) {
new NativeTest().sayHello();
}
}
Run Code Online (Sandbox Code Playgroud)
我编译该类,然后用于javah NativeTest生成头文件.
签发后javah,我收到此警告:
Warning: The javah tool is planned to be removed in the next major
JDK release. The tool has been superseded by the '-h' option added
to javac in JDK 8. Users are recommended to migrate to using the
javac '-h' option; see the javac man page for …Run Code Online (Sandbox Code Playgroud) 使用 Swift 4,我有以下代码尝试向 REST API 发出 POST 请求:
spinner.startAnimation(self)
btnOk.isEnabled = false
btnCancel.isEnabled = false
attemptPost()
spinner.stopAnimation(self)
btnOk.isEnabled = true
btnCancel.isEnabled = true
Run Code Online (Sandbox Code Playgroud)
执行此操作的函数(Constants并且Request是我创建的用于创建请求对象并保存常用数据的类):
func attemptPost() {
let url = Constants.SERVICE_URL + "account/post"
let body: [String : Any] =
["firstName": txtFirstName.stringValue,
"lastName": txtLastName.stringValue,
"email": txtEmail.stringValue,
"password": txtPassword.stringValue];
let req = Request.create(urlExtension: url, httpVerb: Constants.HTTP_POST, jsonBody: body)
let task = URLSession.shared.dataTask(with: req) { data, response, err in
guard let data = data, err == nil else { …Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式在 macOS 应用程序中显示一个窗口。我想以编程方式执行此操作的原因是因为用户单击“登录”按钮,结果函数取决于登录是否成功。如果成功,则会显示该窗口;否则,就不是。
这是我的 Xcode 窗口的屏幕截图:
这是我在代码中尝试的内容(Alert是我创建的一个类,旨在使显示NSAlert对话框更容易):
@IBAction func btnLogin_Click(_ sender: Any) {
let email = txtEmail.stringValue
if(email.isEmpty) {
Alert.show(parent: view.window!, message: "Email is required.")
return
}
let password = txtPassword.stringValue
if(password.isEmpty) {
Alert.show(parent: view.window!, message: "Password is required.")
return
}
// this does not work, even though I gave the window and view controllers
// both identifiers in the storyboard
self.storyboard?.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier("wcStores"))
}
Run Code Online (Sandbox Code Playgroud)
Apple 的文档NSStoryboard.SceneIdentifier几乎不存在,而且我见过的其他方法似乎与 Swift 的早期版本有关。
我究竟做错了什么?
我echo在Bash脚本中有一个语句块,我需要管道到FTP命令.我有这个工作,但我需要无条件地做.
所以我编写了一个虚拟if语句,如下所示:
if [[ 1 -eq 1 ]]; then
echo "..."
# ...
fi | ftp -n
Run Code Online (Sandbox Code Playgroud)
我尝试了一个do ... done没有条件的直接块,但它不喜欢那个(Syntax error: got do, expecting Newline).
显然,这是有效的,但有没有办法消除if声明并do在Bash中有一个"匿名"或"无条件"的阻止?我必须将所有输出传递给FTP,但只输出该块的输出; 脚本的其余部分由我的脚本进行实际处理.
只是好奇.