Setting a Swift @lazy array inside a subclass of an Obj-C class crashes
| Originator: | jgallagher | ||
| Number: | rdar://17129688 | Date Originated: | 6/3/2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 8.0 |
| Classification: | Crash | Reproducible: | Always |
The following AppDelegate crashes when trying to set the value of "anArray":
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
@lazy var anArray = []
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
anArray = ["B", "C"]
return true
}
}
Steps to Reproduce:
1. Create a new Single View application.
2. Replace the AppDelegate with the following:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
@lazy var anArray = []
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
anArray = ["B", "C"]
return true
}
}
3. Run the app.
Expected Results:
Application runs on the 32-bit simulator
Actual Results:
Application crashes on "anArray = ["B", "C"]" with EXC_BAD_ACCESS
Version:
iOS 8.0 (537)
Notes:
Configuration:
iPhone 4s and 5s simulator (presumably others too)
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!