Error[8]: Undefined offset: 4, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我是 Swift 3的新手,想创建一个To-Do-List.但是在viewDidLoad中,由于UILongPressGestureRecognizer,应用程序总是崩溃.我在互联网上搜索,但我找不到有效的解决方案. 这是我的代码,每次在UILongPressGestureRecognizer的行中都显示“Thread 1:breakpoint 1.1”: class ViewController 我是 Swift 3的新手,想创建一个To-Do-List.但是在vIEwDIDLoad中,由于UILongPressGestureRecognizer,应用程序总是崩溃.我在互联网上搜索,但我找不到有效的解决方案.

这是我的代码,每次在UILongPressGestureRecognizer的行中都显示“Thread 1:breakpoint 1.1”:

class VIEwController: UIVIEwController,UItableVIEwDelegate {@IBOutlet weak var newbutton: UIbutton!@IBOutlet weak var tableVIEw: UItableVIEw!@IBOutlet weak var editbutton: UIbutton!var todoList = Todo.load(){    dIDSet{        Todo.save(todoList)    }}overrIDe func vIEwDIDLoad() {    super.vIEwDIDLoad()    tableVIEw.delegate = self    tableVIEw.dataSource = self    let lpgr = UILongPressGestureRecognizer(target: self,action: #selector(VIEwController.handleLongPress(_:)))    lpgr.minimumPressDuration = 1.2    tableVIEw.addGestureRecognizer(lpgr)}func handleLongPress(_ gesture: UILongPressGestureRecognizer){    if gesture.state != .began { return }    let pt = gesture.location(in: tableVIEw)    let path = tableVIEw.indexPathForRow(at: pt)    if let row = (path as NSIndexPath?)?.row,let cell = tableVIEw.cellForRow(at: path!){    showPopup(sender: cell,mode: "edit",text: todoList[row],row: row)    }}

这是todo.txt文件的代码:

struct Todo {static func save(_ data: [String]){    if let url = docUrl(for: "todo.txt"){        do {            let str = data.joined(separator: "\n")            try str.write(to: url,atomically: true,enCoding: .utf8)        } catch {            print(error)        }    }}static func load() -> [String] {    if let url = docUrl(for: "todo.txt"){        do{            let str = try String(contentsOf: url,enCoding: .utf8)            return str.characters                .split {
Error Domain=NSCocoaErrorDomain Code=260 "The file “todo.txt” Couldn’t be opened because there is no such file." UserInfo={NSfilePath=/Users/mkartds/library/Developer/CoreSimulator/Devices/5D70E1CB-6D29-49E4-BCD1-316B5022F085/data/Containers/Data/Application/34869E75-E498-4674-B504-E7867935E3FE/documents/todo.txt,NSUnderlyingError=0x61000004a830 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
== "\n"} .map { String(
private static func docUrl() -> URL? {    let bundle = Bundle.main    let path = bundle.path(forResource: "todo",ofType: "txt")    let fileURL = URL(fileURLWithPath: path)    return fileURL}
)} } catch { print(error) } } return []}private static func docUrl(for filename: String) -> URL? { let urls = fileManager.default.urls(for: .documentDirectory,in: .userDomainMask) if let docDir = urls.first { return docDir.appendingPathComponent(filename) } return nil}

}

这是我的错误报告:

[+++]

(LLDB)

我该怎么办?

解决方法 假设您已在项目的目标中添加了todo.txt文件.

尝试使用以下方法更新docUrl方法,

[+++]

停用断点:

总结

以上是内存溢出为你收集整理的ios – Swift 3中的UILongPressGestureRecognizer全部内容,希望文章能够帮你解决ios – Swift 3中的UILongPressGestureRecognizer所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我是 Swift 3的新手,想创建一个To-Do-List.但是在viewDidLoad中,由于UILongPressGestureRecognizer,应用程序总是崩溃.我在互联网上搜索,但我找不到有效的解决方案. 这是我的代码,每次在UILongPressGestureRecognizer的行中都显示“Thread 1:breakpoint 1.1”: class ViewController 我是 Swift 3的新手,想创建一个To-Do-List.但是在vIEwDIDLoad中,由于UILongPressGestureRecognizer,应用程序总是崩溃.我在互联网上搜索,但我找不到有效的解决方案.

这是我的代码,每次在UILongPressGestureRecognizer的行中都显示“Thread 1:breakpoint 1.1”:

class VIEwController: UIVIEwController,UItableVIEwDelegate {@IBOutlet weak var newbutton: UIbutton!@IBOutlet weak var tableVIEw: UItableVIEw!@IBOutlet weak var editbutton: UIbutton!var todoList = Todo.load(){    dIDSet{        Todo.save(todoList)    }}overrIDe func vIEwDIDLoad() {    super.vIEwDIDLoad()    tableVIEw.delegate = self    tableVIEw.dataSource = self    let lpgr = UILongPressGestureRecognizer(target: self,action: #selector(VIEwController.handleLongPress(_:)))    lpgr.minimumPressDuration = 1.2    tableVIEw.addGestureRecognizer(lpgr)}func handleLongPress(_ gesture: UILongPressGestureRecognizer){    if gesture.state != .began { return }    let pt = gesture.location(in: tableVIEw)    let path = tableVIEw.indexPathForRow(at: pt)    if let row = (path as NSIndexPath?)?.row,let cell = tableVIEw.cellForRow(at: path!){    showPopup(sender: cell,mode: "edit",text: todoList[row],row: row)    }}

这是todo.txt文件的代码:

struct Todo {static func save(_ data: [String]){    if let url = docUrl(for: "todo.txt"){        do {            let str = data.joined(separator: "\n")            try str.write(to: url,atomically: true,enCoding: .utf8)        } catch {            print(error)        }    }}static func load() -> [String] {    if let url = docUrl(for: "todo.txt"){        do{            let str = try String(contentsOf: url,enCoding: .utf8)            return str.characters                .split {
Error Domain=NSCocoaErrorDomain Code=260 "The file “todo.txt” Couldn’t be opened because there is no such file." UserInfo={NSfilePath=/Users/mkartds/library/Developer/CoreSimulator/Devices/5D70E1CB-6D29-49E4-BCD1-316B5022F085/data/Containers/Data/Application/34869E75-E498-4674-B504-E7867935E3FE/documents/todo.txt,NSUnderlyingError=0x61000004a830 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
== "\n"} .map { String(
private static func docUrl() -> URL? {    let bundle = Bundle.main    let path = bundle.path(forResource: "todo",ofType: "txt")    let fileURL = URL(fileURLWithPath: path)    return fileURL}
)} } catch { print(error) } } return []}private static func docUrl(for filename: String) -> URL? { let urls = fileManager.default.urls(for: .documentDirectory,in: .userDomainMask) if let docDir = urls.first { return docDir.appendingPathComponent(filename) } return nil}

}

这是我的错误报告:

(LLDB)

我该怎么办?

解决方法 假设您已在项目的目标中添加了todo.txt文件.

尝试使用以下方法更新docUrl方法,

[+++]

停用断点:

总结

以上是内存溢出为你收集整理的ios – Swift 3中的UILongPressGestureRecognizer全部内容,希望文章能够帮你解决ios – Swift 3中的UILongPressGestureRecognizer所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
ios – Swift 3中的UILongPressGestureRecognizer_app_内存溢出

ios – Swift 3中的UILongPressGestureRecognizer

ios – Swift 3中的UILongPressGestureRecognizer,第1张

概述我是 Swift 3的新手,想创建一个To-Do-List.但是在viewDidLoad中,由于UILongPressGestureRecognizer,应用程序总是崩溃.我在互联网上搜索,但我找不到有效的解决方案. 这是我的代码,每次在UILongPressGestureRecognizer的行中都显示“Thread 1:breakpoint 1.1”: class ViewController 我是 Swift 3的新手,想创建一个To-Do-List.但是在vIEwDIDLoad中,由于UILongPressGestureRecognizer,应用程序总是崩溃.我在互联网上搜索,但我找不到有效的解决方案.

这是我的代码,每次在UILongPressGestureRecognizer的行中都显示“Thread 1:breakpoint 1.1”:

class VIEwController: UIVIEwController,UItableVIEwDelegate {@IBOutlet weak var newbutton: UIbutton!@IBOutlet weak var tableVIEw: UItableVIEw!@IBOutlet weak var editbutton: UIbutton!var todoList = Todo.load(){    dIDSet{        Todo.save(todoList)    }}overrIDe func vIEwDIDLoad() {    super.vIEwDIDLoad()    tableVIEw.delegate = self    tableVIEw.dataSource = self    let lpgr = UILongPressGestureRecognizer(target: self,action: #selector(VIEwController.handleLongPress(_:)))    lpgr.minimumPressDuration = 1.2    tableVIEw.addGestureRecognizer(lpgr)}func handleLongPress(_ gesture: UILongPressGestureRecognizer){    if gesture.state != .began { return }    let pt = gesture.location(in: tableVIEw)    let path = tableVIEw.indexPathForRow(at: pt)    if let row = (path as NSIndexPath?)?.row,let cell = tableVIEw.cellForRow(at: path!){    showPopup(sender: cell,mode: "edit",text: todoList[row],row: row)    }}

这是todo.txt文件的代码:

struct Todo {static func save(_ data: [String]){    if let url = docUrl(for: "todo.txt"){        do {            let str = data.joined(separator: "\n")            try str.write(to: url,atomically: true,enCoding: .utf8)        } catch {            print(error)        }    }}static func load() -> [String] {    if let url = docUrl(for: "todo.txt"){        do{            let str = try String(contentsOf: url,enCoding: .utf8)            return str.characters                .split {
Error Domain=NSCocoaErrorDomain Code=260 "The file “todo.txt” Couldn’t be opened because there is no such file." UserInfo={NSfilePath=/Users/mkartds/library/Developer/CoreSimulator/Devices/5D70E1CB-6D29-49E4-BCD1-316B5022F085/data/Containers/Data/Application/34869E75-E498-4674-B504-E7867935E3FE/documents/todo.txt,NSUnderlyingError=0x61000004a830 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
== "\n"} .map { String(
private static func docUrl() -> URL? {    let bundle = Bundle.main    let path = bundle.path(forResource: "todo",ofType: "txt")    let fileURL = URL(fileURLWithPath: path)    return fileURL}
)} } catch { print(error) } } return []}private static func docUrl(for filename: String) -> URL? { let urls = fileManager.default.urls(for: .documentDirectory,in: .userDomainMask) if let docDir = urls.first { return docDir.appendingPathComponent(filename) } return nil}

}

这是我的错误报告:

(LLDB)

我该怎么办?

解决方法 假设您已在项目的目标中添加了todo.txt文件.

尝试使用以下方法更新docUrl方法,

停用断点:

总结

以上是内存溢出为你收集整理的ios – Swift 3中的UILongPressGestureRecognizer全部内容,希望文章能够帮你解决ios – Swift 3中的UILongPressGestureRecognizer所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1002302.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存