简体   繁体   中英

Swift 2 failing to cast UIView to GPUImageView

I'm trying to use Brad Larson's amazing GPUImage framework in Swift 2 and having problems. Being new to Swift (but fairly good in Obj-C) I'm not sure if it's a Swift or GPUImage bug or my ineptitude...

I've followed Brad's instructions for adding GPUImage as a framework in my iOS project (Xcode 7.0 beta 5), and on the whole things look good.

But I then as a test put in the few lines of code on Brad's blog ( http://www.sunsetlakesoftware.com/2014/06/30/exploring-swift-using-gpuimage ) to try the 'tiny starting application' and although the app compiles OK, I get a runtime error (running on the device) of

Could not cast value of type 'UIView' (0x19842b510) to 'GPUImageView' (0x10016b548).

I've used GPUImage successfully in Obj-C in the past so I understand the theory but this is new... Any ideas? Is this just an early Swift 2 issue, or an Xcode beta problem?

(Incidentally, in the code from Brad's blog page I did change the cast syntax from the Swift 1 as to the Swift 2 as! )

The answer: ensure self.view is set as a GPUImageView in the storyboard. (Thanks Brad - unbelievable support as ever...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM