Using the NSKeyedArchiver on a Swift object causes access to its properties to crash
| Originator: | michael.mcguire | ||
| Number: | rdar://18544533 | Date Originated: | 10/3/2014 |
| Status: | Open | Resolved: | |
| Product: | Xcode | Product Version: | 6.1 GM |
| Classification: | Crash | Reproducible: | Yes |
Summary: Creating a Swift object that inherits from NSObject and implements NSCoding can cause crashes when accessing properties on that object after it has been encoded Steps to Reproduce: _Only occurs on device, not simulator_ 1. Create Swift class that inherits from NSObject, NSCoding 2. Add Dictionary property [Int:Int] 3. Implement NSCoding protocols, including the dictionary 4. Use NSKeyedArchiver to write the object out 5. Using the same instance, try to modify the contents of the dictionary property Full code for reproduction has been included in attached ZIP and is also posted here: https://gist.github.com/MichaelMcGuire/5fdc7aef84b35699dba4 Expected Results: No crash Actual Results: Get an EXC_BAD_ACCESS Version: Xcode 6.1 GM (6A1042b) Notes: Configuration: Occurs on an iPhone 5s running iOS 8.0.2. Does not occur in the simulator Attachments: 'crashReproduction.zip' was successfully uploaded. UPDATE: Apple Developer Relations10-Feb-2015 01:51 PM We believe this issue has been addressed in the latest Xcode 6.3 beta, including iOS 8.3 SDK with Swift 1.2. Please test with this release. If you still have issues, please include any relevant logs or information that could help us investigate. This is a pre-release version of the complete Xcode developer toolset for Mac, iPhone, iPad, and Apple Watch. This release requires OS X Yosemite. Xcode 6.3 - Build 6D520o https://developer.apple.com/xcode/downloads/
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!