automatic-ref-counting

iOS 7.0 and ARC: UITableView never deallocated after rows animation

佐手、 提交于 2019-11-27 02:17:07
问题 I have a very simple test app with ARC. One of the view controllers contains UITableView. After making row animations ( insertRowsAtIndexPaths or deleteRowsAtIndexPaths ) UITableView (and all cells) never deallocated. If I use reloadData , it works fine. No problems on iOS 6, only iOS 7.0. Any ideas how to fix this memory leak? -(void)expand { expanded = !expanded; NSArray* paths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:0 inSection:0], [NSIndexPath indexPathForRow:1 inSection

Automatic Reference Counting Issue: Passing address of non-local object to __autoreleasing parameter for write-back

自闭症网瘾萝莉.ら 提交于 2019-11-27 02:12:33
问题 I'm trying to pass pointer to pointer to a method, but apparently ARC has some issues with how I'm doing it. Here the two methods: + (NSString *)personPropertyNameForIndex:(kSHLPersonDetailsTableRowIndex)index { static NSArray *propertyNames = nil; (nil == propertyNames) ? [self SHL_initPersonPropertyNamesWithArray:&propertyNames] : NULL; } + (void)SHL_initPersonPropertyNamesWithArray:(NSArray **)theArray { *theArray = [[NSArray alloc] initWithObjects:@"name", @"email", @"birthdate", @"phone"

Under ARC, are Blocks automatically copied when assigned to an ivar directly?

本小妞迷上赌 提交于 2019-11-27 02:08:23
问题 Assume the following code under ARC, typedef void (^MyResponseHandler) (NSError *error); @interface MyClass : NSObject { MyResponseHandler _ivarResponseHandler; } - (void)myMethod:(MyResponseHandler)responseHandler { _ivarResponseHandler = responseHandler; ... } Question: Is the block automatically copied to the heap when assigned to the ivar? My previous question implied that it is copied when assigned through a @property . But, today I used the above code and received an EXC_BAD_ACCESS that

Objective C - Custom setter with ARC?

拜拜、爱过 提交于 2019-11-27 02:03:20
问题 Here is how I used to write a custom retained setter before: - (void)setMyObject:(MyObject *)anObject { [_myObject release], _myObject = nil; _myObject = [anObject retain]; // Other stuff } How can I achieve this with ARC when the property is set to strong. How can I make sure that the variable has strong pointer? 回答1: The strong takes care of itself on the ivar level, so you can merely do - (void)setMyObject:(MyObject *)anObject { _myObject = anObject; // other stuff } and that's it. Note:

How to disable ARC for a single file in Xcode 5?

会有一股神秘感。 提交于 2019-11-27 02:03:16
问题 I recently downloaded Xcode 5, and it's now my primary IDE. However, I now need to disable Automatic Reference Counting for a single file in my project. In Xcode 4, I went to the Build Phases tab under my target, and I could double click the on the right side of a row in the Compile Sources section, add -fno-objc-arc to the list of compiler flags, and be off. In 5, however, the column seems to be unclickable: So, how do I do this? 回答1: Well, I just tried and found that you must had dragged

Link Errors with Parse.framework iOS

荒凉一梦 提交于 2019-11-27 01:39:37
问题 I tried importing the parse framework in my project. I made sure it is liked with my project and I couldn't find anything about whether it is 'arc sensitive' or not. My project is arc based. This is the error I'm getting: Undefined symbols for architecture i386: "_SCNetworkReachabilityCreateWithName", referenced from: -[PFCommandCache init] in Parse(PFCommandCache.o) +[PFInternalUtils(Reachability) isParseReachable] in Parse(PFInternalUtils.o) "_SCNetworkReachabilityGetFlags", referenced from

Retain Cycle in ARC

情到浓时终转凉″ 提交于 2019-11-27 01:38:40
I have never worked on non ARC based project. I just came across a zombie on my ARC based project. I found it was because of retain cycle.I am just wondering what is a retain cycle.Can Could you give me an example for retain cycle? A retain cycle is a situation when object A retains object B , and object B retains object A at the same time * . Here is an example: @class Child; @interface Parent : NSObject { Child *child; // Instance variables are implicitly __strong } @end @interface Child : NSObject { Parent *parent; } @end You can fix a retain cycle in ARC by using __weak variables or weak

Is it possible to debug “Terminated due to memory error”?

谁都会走 提交于 2019-11-27 01:31:02
In a certain (consistent) point when my app is running, I consistently get the xcode error message Terminated due to memory error. I cannot find the code causing the error, but I can tell what code is near the error (using breakpoints). The error is caused directly after returning a certain cell in my implemenation of the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath UITableViewDataSource delegate method. I can confirm that it is returning a valid UITableViewCell , but I think that explaining and posting that entire method would be a

Set delegates to nil under ARC?

≡放荡痞女 提交于 2019-11-27 01:28:00
问题 I'm writing iOS apps using ARC and targeting iOS 5+. Suppose I write a custom view object that has a delegate property. In declaring the delegate property, I make it a weak reference to avoid a retain cycle, so that when the actual delegate object (the controller) is destroyed, my custom view will also be destroyed, as follows: @interface MyCustomView : UIView @property (nonatomic, weak) id<MyCustomViewDelegate> delegate; @end All is good. Ok, so now I'm writing the controller object, and it

Should I still copy/Block_copy the blocks under ARC?

北慕城南 提交于 2019-11-27 01:24:25
问题 I've just stumbled over the following SO topic: Why should we copy blocks rather than retain? which has the following sentence: However, as of iOS 6 they are treated as regular objects so you don't need to worry. I was really confused by this assertion that is why I am asking: does this assertion really imply that Objective-C developers do not need to @property (copy) blockProperties or [^(...){...) {} copy] to copy blocks and their contents from stack to heap anymore? I hope the description