在Swift 3/Xcode8.1/10.12.2中我试图使用NSOpenPanel来获取带有以下代码的文本文件,由DenBeke编写
@IBAction func browseFile(sender: AnyObject) {
let dialog = NSOpenPanel();
dialog.title = "Choose a .txt file";
dialog.allowedFileTypes = ["txt"];
if (dialog.runModal() == NSModalResponseOK)
{
let result = dialog.url // Pathname of the file
if (result != nil) {
let path = result!.path
print("browseFile path: \(path)")
//filename_field.stringValue = path
}
} else {
// User clicked on "Cancel"
return
}
}
Run Code Online (Sandbox Code Playgroud)
代码按预期打开一个打开的对话框,我可以选择一个文件.单击打开按钮会使应用程序崩溃.在控制台中,我得到:
FI_TFloatingInputWindowController对象0x60800009c0c0在已经解除分配时过度释放; 打破objc_overrelease_during_dealloc_error进行调试
当我运行代码并打开对话框时,我得到了控制台
[默认] [错误]无法获取URL容器:file:/// Users/ruediheimlicher/Documents/LoggerdataDir/Messungen /,错误:错误域= BRCloudDocsErrorDomain代码= 12"未找到应用程序库:'com.apple.Documents' "UserInfo = {NSDescription =未找到应用程序库:'com.apple.Documents'}
但这不会影响应用程序.
在网络上有更多NSOpen或NSSave对话框的示例,代码略有不同,但每个人都得到相同的结果:崩溃,以及控制台上完全相同的错误.
在我的代码尝试中是否存在错误,甚至是与Swift3/sierra一起使用的示例?
我有一个新的 stk500v2 编程器(Pololu),想读取 atmega8 的保险丝。对于我的老程序员,我使用命令
avrdude -v -p atmega8 -P /dev/cu.usbmodem002938642 -c stk500v2
Run Code Online (Sandbox Code Playgroud)
并在 2 行上得到了 lfuse 和 hfuse
现在我只得到
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9307 (probably m8)
Run Code Online (Sandbox Code Playgroud)
使用
avrdude -v -p atmega8 -P /dev/cu.usbmodem002938642 -c stk500v2 -U hfuse:r:-:h
Run Code Online (Sandbox Code Playgroud)
我明白了
avrdude: reading hfuse memory:
Reading | ################################################## | 100% 0.00s
avrdude: writing output file "<stdout>"
0xd9
Run Code Online (Sandbox Code Playgroud)
与 lfuse 相同。有没有办法使用相同的命令获取 hfuse 和 lfuse ?
我想在每次计时器触发时更新选择器函数中计时器的 userInfo。
用户信息:
var timerDic = ["count": 0]
Run Code Online (Sandbox Code Playgroud)
定时器:
Init: let timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("cont_read_USB:"), userInfo: timerDic, repeats: true)
Run Code Online (Sandbox Code Playgroud)
选择器功能:
public func cont_read_USB(timer: NSTimer)
{
if var count = timer.userInfo?["count"] as? Int
{
count = count + 1
timer.userInfo["count"] = count
}
}
Run Code Online (Sandbox Code Playgroud)
我在最后一行出现错误:
“有什么对象吗?” 没有名为“下标”的成员
这里有什么问题?在 Objective_C 中,此任务与NSMutableDictionary
asuserInfo
我想将Swift类集成到UIViewController类中。我认为所有设置都正确。我有一个带有功能的rURLTask:NSObject类:
@objc public func primer() {
print("primer")
}
Run Code Online (Sandbox Code Playgroud)
在我的.swift文件中,可以使用以下命令从我的Objective-C类进行调用:
[URLTask primer];
Run Code Online (Sandbox Code Playgroud)
而且打印效果很好。另一个功能是:
@objc public func ladeURL(url: URL?) {
print("loadURL")
}
Run Code Online (Sandbox Code Playgroud)
但是我无法从Objective-C调用此代码。我试着写:
NSURL* testURL = [NSURL URLWithString:@"http://www.google.com"];
[URLTask ladeURL:testURL];
Run Code Online (Sandbox Code Playgroud)
我得到错误:
'rURLTask'的可见@interface没有声明选择器'ladeURL:'
我认为这是一个非常基本的错误。在另一个项目中的Swift 3中使用Objective-C效果很好。
我是阿杜诺新手。我选择示例 Blink 并尝试更改循环中的时间。该文件是只读的。按照教程,我尝试将其保存在我的素描本文件夹中。
文件>另存为
呈灰色显示。我将示例文件夹从 Arduino/content/examples 中的位置复制到我的素描本中。相同的结果。无法编辑。出了什么问题?
Arduino nano 每个
Arduino 18.10
MacOS 10.14
swift ×2
arduino ×1
atmega ×1
avrdude ×1
edit ×1
macos ×1
macos-sierra ×1
nsopenpanel ×1
nssavepanel ×1
objective-c ×1
swift3 ×1
timer ×1
userinfo ×1