> On Dec 6, 2016, at 11:51 AM, Doug Hill <cocoa...@breaqz.com> wrote: > > I've wondered about this before, but maybe some Objective-C runtime experts > know. > > Does writing directly to the ivar backing a property bypass the ARC features > of the property. For example, will a strong property be retained if you write > directly to the ivar?
Yes, under ARC assigning to a strong ivar and assigning via a strong property are identical with respect to the resulting retain count semantics (otherwise typically constructed ARC-based setter methods wouldn’t work). > > If not, that's your problem. > > Doug > >> On Dec 6, 2016, at 11:44 AM, Carl Hoefs <newsli...@autonomy.caltech.edu >> <mailto:newsli...@autonomy.caltech.edu>> wrote: >> >> I get the following crash in my iOS 9 app simply by adding a CALayer to the >> current view controller's self.view.layer and then dismissing the current >> view controller. Simplified code: >> >> @property (strong,nonatomic) CALayer *layer; >> . . . >> _layer = [[CALayer alloc] init]; >> [_layer setDelegate: self]; >> [self.view.layer addSublayer:_layer]; >> >> Upon dismissing the VC: >> >> [self dismissViewControllerAnimated:YES completion:nil]; >> >> The following exception occurs: >> >> (lldb) bt >> * thread #1: tid = 0x121bd, 0x22c2c68a libobjc.A.dylib`objc_retain + 10, >> queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, >> address=0xb0000010) >> frame #0: 0x22c2c68a libobjc.A.dylib`objc_retain + 10 >> frame #1: 0x27a2a22a UIKit`-[UIView(Hierarchy) subviews] + 330 >> frame #2: 0x27b3e1ea UIKit`discardEngineRecursive + 118 >> frame #3: 0x27a2fd06 UIKit`-[UIView dealloc] + 630 >> frame #4: 0x2336cd98 CoreFoundation`-[__NSDictionaryM dealloc] + 132 >> frame #5: 0x22c2cf8a libobjc.A.dylib`objc_object::sidetable_release(bool) >> + 150 >> frame #6: 0x22c2d3cc libobjc.A.dylib`(anonymous >> namespace)::AutoreleasePoolPage::pop(void*) + 388 >> frame #7: 0x23363f30 CoreFoundation`_CFAutoreleasePoolPop + 16 >> frame #8: 0x23415c56 CoreFoundation`__CFRunLoopRun + 1598 >> frame #9: 0x233641c8 CoreFoundation`CFRunLoopRunSpecific + 516 >> frame #10: 0x23363fbc CoreFoundation`CFRunLoopRunInMode + 108 >> frame #11: 0x24980af8 GraphicsServices`GSEventRunModal + 160 >> frame #12: 0x27a9c434 UIKit`UIApplicationMain + 144 >> * frame #13: 0x001b655e ProteinFold`main(argc=1, argv=0x0043bbc8) + 122 at >> main.m:14 >> >> If I remove the CALayer first before the >> -dismissViewControllerAnimated:completion:, it doesn't crash: >> >> [layer removeFromSuperlayer]; >> >> Why do I need to explicitly remove my added CALayer before dismissing the >> VC? Note: If I declare layer as weak, the crash does not occur, but neither >> does the layer display onscreen. >> -Carl >> >> >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40breaqz.com >> <https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40breaqz.com> >> >> This email sent to cocoa...@breaqz.com <mailto:cocoa...@breaqz.com> > > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com > <mailto:Cocoa-dev@lists.apple.com>) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > <http://lists.apple.com/> > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com > <https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com> > > This email sent to david.dun...@apple.com <mailto:david.dun...@apple.com> -- David Duncan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com