Skip to content

Instantly share code, notes, and snippets.

@diegosanchezr
Last active January 28, 2016 13:08
Show Gist options
  • Save diegosanchezr/0d733408e2e49817cdf8 to your computer and use it in GitHub Desktop.
Save diegosanchezr/0d733408e2e49817cdf8 to your computer and use it in GitHub Desktop.
Crash Xcode 7.3 b2
import UIKit
public class BaseCellT<BubbleViewType where BubbleViewType:UIView>: UICollectionViewCell {
override init(frame: CGRect) {
super.init(frame: frame)
self.bubbleView = self.createBubbleView()
}
public private(set) var bubbleView: BubbleViewType!
func createBubbleView() -> BubbleViewType! {
assert(false, "Override in subclass")
return nil
}
}
public final class PhotoCell: BaseCellT<UIImageView> {
override init(frame: CGRect) {
super.init(frame: frame)
}
override func createBubbleView() -> UIImageView! {
return UIImageView()
}
}
public final class TextCell: BaseCellT<UIView> {
override init(frame: CGRect) {
super.init(frame: frame)
}
override func createBubbleView() -> UIView! {
return UIView()
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let photoCell = PhotoCell(frame: CGRect.zero)
let textCell = TextCell(frame: CGRect.zero)
print(photoCell)
print(textCell)
}
}
@diegosanchezr
Copy link
Author

Random EXC_BAD_ACCESS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment