automatic-ref-counting

What kind of leaks does automatic reference counting in Objective-C not prevent or minimize?

ぐ巨炮叔叔 提交于 2019-12-17 00:21:09
问题 In the Mac and iOS platforms, memory leaks are often caused by unreleased pointers. Traditionally, it has always been of utmost importance to check your allocs, copies and retains to make sure each has a corresponding release message. The toolchain that comes with Xcode 4.2 introduces automatic reference counting (ARC) with the latest version of the LLVM compiler, that totally does away with this problem by getting the compiler to memory-manage your stuff for you. That's pretty cool, and it

ARC project with delegate reference fails compiling

天大地大妈咪最大 提交于 2019-12-14 03:59:35
问题 I'm having trouble implementing the Facebook SDK in an iOS project and I suspect that this line is to blame: [facebook authorize:permissions delegate:self]; When I try to run it in my ARC project, it will not allow the delegate:self to remain. Instead it says there is an "ARC Error: no visible @interface for 'Facebook' declares the selector 'authorize:delegate:'" I can compile with this: [facebook authorize:permissions]; but I don't think Facebook and the app communicate properly by doing so.

UITableView reloadData EXC_BAD_ACESS code=2

℡╲_俬逩灬. 提交于 2019-12-14 03:53:32
问题 I have this code for loading the UITableView: - (int)numberOfSectionsInTableView:(UITableView *)tableView { if (tableView == self.peopleTableView) return [self.people count]; else return [[[self.scheduleDays objectAtIndex:self.dayInt] periods] count]; } - (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (tableView == self.peopleTableView) return [[self.people objectAtIndex:section] count]; else return 1; } - (NSString *)tableView:(UITableView *)tableView

Passing objects safely as opaque context params under ARC

假如想象 提交于 2019-12-14 03:46:01
问题 Under manual memory management, I use this pattern fairly often: NSString * myStr = /* some local object */ [UIView beginAnimation:@"foo" context:(void *)[myStr retain]]; And then, later and asynchronously: - (void)animationDidStop:(NSString *)anim finished:(NSNumber *)num context:(void *)context { NSString * contextStr = (NSString *)context; // ... [contextStr release]; } i.e. I manually managed the lifetime of an object used as an opaque context. (This is true for the old UIView animations

How to ignore “No visible @interface for X declares the selector”?

﹥>﹥吖頭↗ 提交于 2019-12-14 03:42:07
问题 Before ARC, I had an "X may not respond to xxx" warning , which is a pretty harmless warning which does not prevent it from compiling. Now, I am trying to convert my project to ARC, and I have an "No visible @interface for X declares the selector xxx" error , which prevents it from compiling. I know exactly what I am doing, and why the warning was there, and I can tell you that the program is correct. Previously, the compiler compiled it with no problem, and should not now stop it from

How can I disable ARC for a single file in a project?

好久不见. 提交于 2019-12-14 02:39:01
问题 I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile right now. I recall hearing that there was a way to disable ARC on a per-file basis, though I have been unable to find this option. Is this possible? How do I disable ARC on a per-file basis? 回答1: It is possible to disable ARC for individual files by adding the -fno-objc-arc compiler flag for those files. You add compiler

Should all reference to programmactically created subviews declared as weak?

空扰寡人 提交于 2019-12-14 02:12:26
问题 I am getting confuse weither reference to subviews i am creating in a view should be declared with the weak or strong keyword when using ARC in iOS5. Here is a sample of my header file: #import <UIKit/UIKit.h> #import <MessageUI/MessageUI.h> @class SCLGridView; @interface MyViewController : UIViewController <UIPopoverControllerDelegate, MFMailComposeViewControllerDelegate> @property (weak, nonatomic) IBOutlet UIView *hiddenBrowserView; @property (strong, nonatomic) SCLGridView *gridView;

Capturing an Objective-C object weakly within C block without declaring an explicit __weak or __block variable

混江龙づ霸主 提交于 2019-12-13 21:14:00
问题 I am capturing a method-scoped object in a C block and I want to avoid retain cycles. Here is my code: ( balloon is a custom view created within my current method) balloon.onAddedToViewHierarchy = ^{ CGRect globalRect = [[UIApplication sharedApplication].keyWindow convertRect:self.frame fromView:self.superview]; CGRect targetFrame = CGRectMake(20, 0, SCREEN_WIDTH - 40, 60); targetFrame.origin.y = below ? globalRect.origin.y + globalRect.size.height + 10 : globalRect.origin.y - 10 - 60/*height

Using ARC for the Cocoa UI of an AudioUnit prevents NSView dealloc from being called

青春壹個敷衍的年華 提交于 2019-12-13 20:05:12
问题 I recently converted my AudioUnit plugin to take advantage of ARC for all the interface code (Cocoa). However, this resulted in the main NSView (the one created by the CocoaViewFactory and returned to the plugin as a property) never having -dealloc called. This made it impossible to dispose of the AUEventListener constructed for the NSView - which is documented to cause crashes - and creates a tonne of memory leaks (none of the Objective-C objects retained by the NSView are deallocated,

Two exactly same SVG paths not drawn exactly the same way

六眼飞鱼酱① 提交于 2019-12-13 15:06:28
问题 I'm drawing two exactly same paths on top of each other to an SVG canvas. The path behind can be seen even though the other path should hide it. Here's the SVG: <svg viewBox="0 0 100 100"> <!-- BLUE PATH --> <path id="blue" d="M 50,50 m 0,-48 a 48,48 0 1 1 0,96 a 48,48 0 1 1 0,-96" stroke="blue" stroke-width="4" fill-opacity="0" style="stroke-dasharray: 302px, 302px; stroke-dashoffset: 0px;"></path> <!-- YELLOW PATH --> <path id="yellow" d="M 50,50 m 0,-48 a 48,48 0 1 1 0,96 a 48,48 0 1 1 0,