我们在生产中有一个应用程序,并在访问User(PFUser的子类)中的新变量时收到了一些EXC_BAD_ACCESS KERN_INVALID_ADDRESS崩溃。
class User : PFUser {
@NSManaged var name: String!
@NSManaged var age: Int
...
var newVariable: Int = 0
}
由于Parse缓存PFUser,因此currentUser的缓存版本(来自先前版本)不包含newVariable。在User.currentUser()上调用.fetch()后,应用程序停止崩溃。
这是崩溃日志:
Thread : Crashed: com.apple.main-thread
0 libGSFontCache.dylib 0x2000000000000 (Missing)
1 APP 0x1001d8b54 AvatarImageView.(updateUI in _0CCBFAE82915B0F511DDDA83596201DC)() -> () (AvatarImageView.swift:119)
2 APP 0x1001d9a48 specialized AvatarImageView.user.setter (AvatarImageView.swift:37)
3 APP 0x1001d783c AvatarImageView.user.setter (AvatarImageView.swift)
4 APP 0x1001dbea4 ProfileHeaderView.(initView in _8556F2EAEF99C54ED4DABB5A0C260DAE)() -> () (ProfileHeaderView.swift:98)
5 APP 0x1001db7f4 ProfileHeaderView.init(type : ProfileHeaderView.ViewType, user : User, buddy : Buddy?) -> ProfileHeaderView (ProfileHeaderView.swift:66)
6 APP 0x10018c49c ProfileViewController.initView() -> () (ProfileViewController.swift:123)
7 APP 0x1000d9258 BaseViewController.viewDidLoad() -> () (BaseViewController.swift:52)
8 APP 0x10018bd64 ProfileViewController.viewDidLoad() -> () (ProfileViewController.swift:79)
9 APP 0x10018bf88 @objc ProfileViewController.viewDidLoad() -> () (ProfileViewController.swift)
10 UIKit 0x1862ec0c0 -[UIViewController loadViewIfRequired] + 996
11 UIKit 0x1863abda8 -[UINavigationController _layoutViewController:] + 72
12 UIKit 0x1863abc80 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 416
13 UIKit 0x1863aaec8 -[UINavigationController _startTransition:fromViewController:toViewController:] + 144
14 UIKit 0x1863aaa6c -[UINavigationController _startDeferredTransitionIfNeeded:] + 868
15 UIKit 0x1863aa694 -[UINavigationController __viewWillLayoutSubviews] + 60
16 UIKit 0x1863aa5fc -[UILayoutContainerView layoutSubviews] + 208
17 UIKit 0x1862e7778 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 656
18 QuartzCore 0x183cf6b2c -[CALayer layoutSublayers] + 148
19 QuartzCore 0x183cf1738 CA::Layer::layout_if_needed(CA::Transaction*) + 292
20 QuartzCore 0x183cf15f8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
21 QuartzCore 0x183cf0c94 CA::Context::commit_transaction(CA::Transaction*) + 252
22 QuartzCore 0x183cf09dc CA::Transaction::commit() + 512
23 QuartzCore 0x183cea0cc CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
24 CoreFoundation 0x1815b0588 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
25 CoreFoundation 0x1815ae32c __CFRunLoopDoObservers + 372
26 CoreFoundation 0x1814dd6a0 CFRunLoopRunSpecific + 416
27 UIKit 0x18635a580 -[UIApplication _run] + 460
28 UIKit 0x186354d90 UIApplicationMain + 204
29 APP 0x1000c3dfc main (AppDelegate.swift:17)
30 libdispatch.dylib 0x18107e8b8 (Missing)