gpt4 book ai didi

ios - libc++abi.dylib : terminating with uncaught exception of type NSException on iOS 7. 1

转载 作者:行者123 更新时间:2023-11-28 09:17:35 29 4
gpt4 key购买 nike

我是编程新手。我将学习使用 Apple 新编程语言 Swift 开发 iOS 应用程序。我关注这个网站(https://developer.apple.com/swift/blog/?id=16)开始。
我将视频中的代码复制到我的 Xcode 项目中。当我在 iOS 8.1 iOS 模拟器中运行该应用程序时一切正常。
但是当我选择 iOS 7.1 iOS 模拟器时出现异常。
然后我将应用程序放入我的 iPhone 5S(iOS 7.1.2),它崩溃了。

下面是我从视频中复制的代码:

import UIKit
class ViewController: UIViewController {
@IBOutlet weak var photoImageView: UIImageView!
let context = CIContext(options: nil)

@IBAction func applyFilter(sender: AnyObject) {
let inputImage = CIImage(image: photoImageView.image)

let randomColor = [kCIInputAngleKey: (Double(arc4random_uniform(314)) / 100)]
let filteredImage = inputImage.imageByApplyingFilter("CIHueAdjust",withInputParameters: randomColor)
let renderedImage = context.createCGImage(filteredImage, fromRect: filteredImage.extent())

photoImageView.image = UIImage(CGImage: renderedImage)
}

override func viewDidLoad() {
super.viewDidLoad()
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}

这是我从控制台得到的:

2014-11-03 16:17:30.645 njnj[2748:60b] -[CIImage imageByApplyingFilter:withInputParameters:]: unrecognized selector sent to instance 0x7fe4e3d165e0
2014-11-03 16:17:30.649 njnj[2748:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CIImage imageByApplyingFilter:withInputParameters:]: unrecognized selector sent to instance 0x7fe4e3d165e0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106c8b495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010852799e objc_exception_throw + 43
2 CoreFoundation 0x0000000106d1c65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000106c7cd8d ___forwarding___ + 973
4 CoreFoundation 0x0000000106c7c938 _CF_forwarding_prep_0 + 120
5 njnj 0x0000000106b934a0 _TFC4njnj14ViewController11applyFilterfS0_FPSs9AnyObject_T_ + 3648
6 njnj 0x0000000106b93a66 _TToFC4njnj14ViewController11applyFilterfS0_FPSs9AnyObject_T_ + 54
7 UIKit 0x000000010753af06 -[UIApplication sendAction:to:from:forEvent:] + 80
8 UIKit 0x000000010753af06 -[UIApplication sendAction:to:from:forEvent:] + 80
9 UIKit 0x000000010753aeb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
10 UIKit 0x0000000107617880 -[UIControl _sendActionsForEvents:withEvent:] + 203
11 UIKit 0x0000000107616dc0 -[UIControl touchesEnded:withEvent:] + 530
12 UIKit 0x0000000107571d05 -[UIWindow _sendTouchesForEvent:] + 701
13 UIKit 0x00000001075726e4 -[UIWindow sendEvent:] + 925
14 UIKit 0x000000010754a29a -[UIApplication sendEvent:] + 211
15 UIKit 0x0000000107537aed _UIApplicationHandleEventQueue + 9579
16 CoreFoundation 0x0000000106c1ad21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
17 CoreFoundation 0x0000000106c1a5f2 __CFRunLoopDoSources0 + 242
18 CoreFoundation 0x0000000106c3646f __CFRunLoopRun + 767
19 CoreFoundation 0x0000000106c35d83 CFRunLoopRunSpecific + 467
20 GraphicsServices 0x000000010baf2f04 GSEventRunModal + 161
21 UIKit 0x0000000107539e33 UIApplicationMain + 1010
22 njnj 0x0000000106b9582e top_level_code + 78
23 njnj 0x0000000106b9586a main + 42
24 libdyld.dylib 0x0000000108ee55fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

希望有人能帮我解决这个问题。(抱歉我的英语不好)

最佳答案

通常“无法识别的选择器发送到实例”(由 -doesNotRecognizeSelector: 产生)表示内存管理问题,通常是过度释放仍在某处引用的对象。

我建议您运行带有内存调试功能的调试版本,以分流应用的内存问题。我建议您通过最新版本的 Xcode 使用 ASan。如果这不是一个选项,您可以将 malloc history 与 guard malloc、scribble 和 NSZombies 一起使用。

关于ios - libc++abi.dylib : terminating with uncaught exception of type NSException on iOS 7. 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26710826/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com