automatic-ref-counting

-fno-objc-arc not working to disable ARC

时光怂恿深爱的人放手 提交于 2019-12-06 20:50:55
问题 I have tried the solution found in this post to disable ARC in AFNetworking files, but to no avail: Any ideas where I am failing? Obviously the simpler the answer the better. I have also read that creating static libraries may help, but this seems complicated. EDITS I have tried deleting derived data and Clean and Build and restarting Xcode. No deals :(. Also, there are no other projects in my workspace. 回答1: Weird thing. I tried adding the -fno-objc-arc flag to some Facebook files and the

NSPointerArray weird compaction

强颜欢笑 提交于 2019-12-06 19:01:11
问题 I have a weak NSPointerArray with some NSObject that has been released. Before calling compact what I see is: (lldb) po [currentArray count] 1 (lldb) po [currentArray pointerAtIndex:0] <nil> (lldb) po [currentArray allObjects] <__NSArrayM 0x16f04f00>( ) That makes sense, but what is really weird is that when I call compact on that array I see the same values! Count still returns 1 and pointerAtIndex:0 is nil . Why the nil hasn't been removed? EDIT Here's the full code (yeah it's XCTesting

How to resolve “no known instance method for selector 'performSelector:withObject:afterDelay:'” when migrating to ARC?

不打扰是莪最后的温柔 提交于 2019-12-06 17:58:32
问题 The ARC migration tool is refusing to accept this code prior to starting with migration: [self.delegate performSelector:@selector(overlayDismissed:) withObject:self afterDelay:0]; The delegate is forced to implement this method with a protocol, and it should work fine: @protocol OverlayDelegate <NSObject> - (void)overlayDismissed:(Overlay*)overlay; @end @interface Overlay : UIImageView { id<OverlayDelegate> delegate; } @property (nonatomic, assign) id<OverlayDelegate> delegate; What's wrong

Object deallocated in ARC mode

十年热恋 提交于 2019-12-06 16:21:46
The object is deallocated in ARC mode and causes crash. My code below; BlockAlertView* alert = [BlockAlertView alertWithTitle:title message:message]; [alert setCancelButtonWithTitle:NSLocalizedString(@"No", @"No Button") block:nil]; [alert addButtonWithTitle:NSLocalizedString(@"Yes", @"Yes Button") block:^{ //Do Something }]; [alert show]; It appears the correct alert view(which is custom UIView) but when I click one of the button it crashes. The crash log; 2015-04-07 22:28:17.065 Test[3213:781570] <BlockAlertView: 0x16bb4160> 2015-04-07 22:33:01.746 Test[3213:781570] *** -[BlockAlertView

Getting a error with implicit conversion of an pointer using Automatic reference Counting Issue

我是研究僧i 提交于 2019-12-06 14:46:15
I am getting an error Implicit conversion of an Objective-C pointer to 'void' is disallowed with ARC -(void)openAnimation { NSValue *contextPoint =[NSValue valueWithCGPoint:self.view.center]; [UIView beginAnimation:nil context:contextPoint]; // getting error here } Can anyone help me to solve this error Thank you So first, I would point out that this type of thing is easier to do with the block based animation methods. For iOS4 and iOS5, Apple recommends that you use those newer methods instead . But to answer your specific question, the context parameter is a void *. ARC doesn't (can't)

Core Plot and Xcode 5.1 - How to convert Core Plot to ARC?

爷,独闯天下 提交于 2019-12-06 14:03:38
I just installed Xcode 5.1 and found that it definitely requires projects to use ARC. I get error: garbage collection is no longer supported when trying to compile Core Plot (version 1.4). Out of curiosity I told Xcode to convert Core Plot to ARC. But it fails with ARC forbids Objective-C objects in struct in file CPTPlatformSpecificFunctions.m . I don't want to dive into Core Plot and break something by trying to fix this or similar errors. Is there a compiler setting I have overlooked? Or will there be a Core Plot version which uses ARC soon? Thanks, Dirk Xcode 5.1 doesn't require projects

Singleton in Objective-C, compatible with ARC and thread safe

醉酒当歌 提交于 2019-12-06 13:37:15
问题 I want to have a thread safe, ARC compatible singleton, but is seems to me that the most common example of singleton that I find, an example pasted here: + (MyClass *)sharedInstance { static MyClass *sharedInstance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ sharedInstance = [[self alloc] init]; // Do any other initialisation stuff here }); return sharedInstance; } doesn't stops other developer from calling [[MyClass alloc] init] and overriding the desired flow. What

ARC and __unsafe_unretained

戏子无情 提交于 2019-12-06 13:13:51
I think I have a pretty good understanding of ARC and the proper use cases for selecting an appropriate lifetime qualifiers ( __strong , __weak , __unsafe_unretained , and __autoreleasing ). However, in my testing, I've found one example that doesn't make sense to me. As I understand it, both __weak and __unsafe_unretained do not add a retain count. Therefore, if there are no other __strong pointers to the object, it is instantly deallocated (with immutable strings being an exception to this rule). The only difference in this process is that __weak pointers are set to nil, and __unsafe

When to use strong or weak for properties

孤街醉人 提交于 2019-12-06 11:42:58
I have a table view as an IBOutlet , and by default XCode sets its property to be strong rather than weak . Sometimes I get a "recieved memory warning" message. So I tried to change many properties from strong to weak , but it doesn't seem to affect the process and things work smoothly. Should I set the outlets to weak, or am I wrong? And most importantly, should I set ALL properties to nil in the viewDidUnload method, or only the IBOutlet s? Rohit Gupta You should set only Strong properties to nil in viewDidUnload . Weak Properties are automatically set to Nil if the destination object is

App crashes when using __bridge for CoreGraphics gradient on ARC

丶灬走出姿态 提交于 2019-12-06 10:38:08
I'm creating an application for iOS 5 and I'm drawing some gradients. The following gradient code I've always used before ARC, but now it does not work on my device anymore (however, it works on the simulator) when I use it several times (so I suppose it's a memory management issue). Anyways, here's the code: CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGFloat locations[] = { 0.0, 1.0 }; NSArray *colors = [NSArray arrayWithObjects:(__bridge id)startColor, (__bridge id)endColor, nil]; CGGradientRef gradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef) colors,