automatic-ref-counting

Compatibility of ARC and Storyboard

此生再无相见时 提交于 2019-11-30 13:39:50
What's the compatibility of ARC and Storyboard considering devices and iOS? Will ARC and Storyboard work on iPhone 3G, 3GS, 4 and 4S? Will ARC and Storyboard work on iOS 4 and 5? Phlibbo ARC runs with 5.0 or higher, Storyboard also needs iOS 5 . Therefore, both are potentially available with the iPhone 3GS and above. EDIT: Obviously, ARC is also compatible with iOS 4.0 and above, once you don't use weak . I briefly tested it, seems to work. That would mean that the iPhone 3G would also be compatible. 来源: https://stackoverflow.com/questions/7815128/compatibility-of-arc-and-storyboard

Explain __weak and __strong usage reasons in SDWebImage code

て烟熏妆下的殇ゞ 提交于 2019-11-30 13:29:19
问题 I think I understand strong and weak keywords well, but I don't understand how it's used in the code below. This code is from SDWebImage by Olivier Poitrey available on github. I understand strong and weak keywords as is described here: Explanation of strong and weak storage in iOS5 The code below uses __weak and __strong keywords in a way that is curious to me. It is not a child-parent relationship or delegate pattern as I am used to seeing weak used. However, I'm sure that this is a pattern

How does the ARC's zeroing weak pointer behavior implemented?

只谈情不闲聊 提交于 2019-11-30 13:21:30
问题 I'm studying ARC. And now about zeroing weak pointer. OK I understood all the features. The semantic of weak reference is just same with weak reference of GC system, but you know, Objective-C doesn't use GC (except special case) so I can't understand how this works. I'm a little complicated guy, so I need to know underlying implementation principal to accept the feature to use. But the problem is it's very hard to find document which describes the principal of zeroing-weak pointer :( IMO, the

ARC and CFRelease?

南楼画角 提交于 2019-11-30 11:37:44
问题 I'm slightly confused. Everywhere I've read, suggest that when using ARC, you still need to release core foundation objects which makes sense, ARC doesn't manage them. However, I've got a method which uses some CF methods/objects which I used CFRelease on, but that then caused the app to crash. Uncommenting my CFRelease s fixes the issue but then I'm assuming I've got a memory leak? Could someone please explain which things need releasing and which don't, or anything else that's wrong with

ARC and autorelease

六月ゝ 毕业季﹏ 提交于 2019-11-30 11:37:18
问题 autorelease is used for returned function object so the caller don't take ownership and callee will release the object in the future. However, ARC is capable to count ownership of caller and release it after use, that is, it can behavior just like Smart Pointer in C++. With ARC, it can get rid of autorelease because autorelease is non-deterministic. The reason I ask for this question is that I do see the returned object calls dealloc earlier in ARC than non-ARC code. This leads me to think

What is the difference in Swift between 'unowned(safe)' and 'unowned(unsafe)'?

纵然是瞬间 提交于 2019-11-30 11:00:52
问题 Apple's Swift Programming Language Guide mentions the capture specifiers unowned(safe) and unowned(unsafe) , in addition to weak and unowned . I (think I) understand the differences between weak and unowned ; but what is the difference between unowned(safe) and unowned(unsafe) ? The guide doesn't say. Please: Don't rely on simply stating an Objective-C equivalent. 回答1: From what I understand, although I can't find a definitive source from Apple, unowned can be broken into two flavors, safe

how to use delegates with Automatic Reference Counting

荒凉一梦 提交于 2019-11-30 10:54:15
问题 I've jumped on the ARC bandwagon. In the past I would have my delegate properties declared like this: @property(assign) id<MyProtocol> delegate; So I thought I would do this under ARC: @property(weak) id<MyProtocol> delegate; Not so. On the @synthesize statement in the .m I have a compile error : *Semantic Issue: Existing ivar 'delegate' for __weak property 'delegate' must be __weak* I HAVE declared it as weak though! Also how do I pass a class implementing a protocol to a weakly referenced

ARC error when declaring delegate ivar

僤鯓⒐⒋嵵緔 提交于 2019-11-30 10:52:44
I am using ARC (no, this is not NDA). I am declaring my ivar in my interface with id itemDelegate; I then declare the property: @property (nonatomic, weak) id<mySecretDelegateYouAreNotSupposedToSeeOnSO> itemDelegate; (with weak instead of assign because of ARC) In my implementation file I simply synthesize it: @synthesize itemDelegate; However, I am getting the error: "Existing ivar 'ItemDelegate' for _weak property 'itemDelegate' must be _weak". Anyone know what's wrong? Thanks for your help. ARC - Automatic Reference Counting Try something like the following ( example from: http://vinceyuan

Collections of zeroing weak references under ARC

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 10:27:22
问题 How can I get an array of zeroing weak references under ARC? I don't want the array to retain the objects. And I'd like the array elements either to remove themselves when they're deallocated, or set those entries to nil. Similarly, how can I do that with a dictionary? I don't want the dictionary to retain the values. And again, I'd like the dictionary elements either to remove themselves when the values are deallocated, or set the values to nil. (I need to retain the keys, which are the

Assignment to ivar in a Block via weak pointer

≯℡__Kan透↙ 提交于 2019-11-30 09:52:06
I have a read-only property isFinished in my interface file: typedef void (^MyFinishedBlock)(BOOL success, NSError *e); @interface TMSyncBase : NSObject { BOOL isFinished_; } @property (nonatomic, readonly) BOOL isFinished; and I want to set it to YES in a block at some point later, without creating a retain cycle to self : - (void)doSomethingWithFinishedBlock:(MyFinishedBlock)theFinishedBlock { __weak MyClass *weakSelf = self; MyFinishedBlock finishedBlockWrapper = ^(BOOL success, NSError *e) { [weakSelf willChangeValueForKey:@"isFinished"]; weakSelf -> isFinished_ = YES; [weakSelf