automatic-ref-counting

How do I know if my program has ARC enabled or not?

谁说我不能喝 提交于 2019-12-20 09:01:24
问题 I create a project with ARC support using the Xcode project wizard. Compared with a program without ARC support, I did not notice any differences. Is there any hint that can tell me if my program supports ARC? I am using XCode 4.2.1 Build 4D502 回答1: You can use __has_feature , maybe logging whether the project has ARC in the console like this: #if __has_feature(objc_arc) // ARC is On NSLog(@"ARC on"); #else // ARC is Off NSLog(@"ARC off"); #endif Alternatively, instead of just logging whether

IBOutlet and viewDidUnload under ARC

最后都变了- 提交于 2019-12-20 08:37:46
问题 There is a similar question to this on SO here, however I just want to clarify something that wasn't fully explained there. I understand that all delegates and outlets - in fact any reference to a "parent" object, to be a good citizen and think about the object graph for a minute - should be zeroing weak references. Due to the nature of zeroing weak pointers automatically dropping to nil on the referenced object's retain count reaching zero, does this mean that setting IBOutlets to nil in

iOS : ARC, not freeing memory

谁说胖子不能爱 提交于 2019-12-20 04:11:57
问题 I've kind of a weird issue with my iOS app. after a while my app goes low in memory so memory warning, everything seems to be fine, but when I check the memory usage I noticed that all the calls to viewDidUnload didn't free up lot of memory, so after a few click in my app, it goes again in memory warning, everything seems to be fine again, but not a lot a memory have been released, so it goes again in memory warning faster, and then it crash (after the third memory warning most of the time).

Issue with NSMakeCollectable when converting to ARC

眉间皱痕 提交于 2019-12-19 19:45:19
问题 I am trying to convert my code to ARC and I have problem with NSMakeCollectable in the ASIRequest library. - (NSString*)encodeURL:(NSString *)string { NSString *newString = NSMakeCollectable([(NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding])) autorelease]); if (newString) { return newString; } return @""; } It is giving me this error:

How do I correct the “Undefined symbols for architecture i386: ”_main" linking issue?

*爱你&永不变心* 提交于 2019-12-19 18:28:27
问题 I am trying to use the KeyChainitemwrapper provided by apple. My project is using ARC but I have turned of ARC on KeyChainitemwrapper.m. I linked the 'security.framework' framework to my project. I am getting this linking issue: Undefined symbols for architecture i386: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) I am new to ios development but my guess is that the

How do I correct the “Undefined symbols for architecture i386: ”_main" linking issue?

假如想象 提交于 2019-12-19 18:28:01
问题 I am trying to use the KeyChainitemwrapper provided by apple. My project is using ARC but I have turned of ARC on KeyChainitemwrapper.m. I linked the 'security.framework' framework to my project. I am getting this linking issue: Undefined symbols for architecture i386: "_main", referenced from: start in crt1.10.6.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) I am new to ios development but my guess is that the

Runtime memory leaked warnings when executing objective-C code within C code with ARC enabled

隐身守侯 提交于 2019-12-19 11:29:39
问题 ARC is enabled and bufferReady is being triggered by a C++ library(non-ARC enabled), and I'm sure I'm missing an ARC cast somewhere. Please advise. Thanks in advance. With the code below: @implementation HelloWorldLayer id refToSelf; //reference to self int shakeCounter = 0; void bufferReady() { if (shakeCounter % 100 == 0) { [refToSelf shakes]; } shakeCounter++; } - (void) shakes { CCRotateBy * rotate = [CCRotateBy actionWithDuration:0.1 angle:2]; CCActionInterval * rotateReverse = [rotate

NSWindowController's window released immediately

别说谁变了你拦得住时间么 提交于 2019-12-19 09:26:49
问题 I'm trying to open a window using a NSWindowController in my app delegate. I created a basic NSWindowController with an associated NIB and try to show the window that way: @implementation MyAppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Show the main window from a separate nib MyWindowController * theWindowController = [[MyWindowController alloc] initWithWindowNibName:@"MyWindowController"]; [theWindowController showWindow:self]; } @end When I launch

ARC __bridge cast Block_copy & Block_release

最后都变了- 提交于 2019-12-19 08:58:51
问题 For some reason I want a block to execute during the next iteration of the run loop, so I came up with: typedef void (^resizer_t)() ; - (void) applyResizer: (resizer_t) resizer { resizer() ; Block_release(resizer) ; } - (void) usage { ... resizer_t resizer = ^() { // stuff } ; [self performSelectorOnMainThread:@selector(applyResizer:) withObject:(__bridge id) Block_copy((__bridge void *) resizer) waitUntilDone:NO] ; } Isn't it ironic that I have to cast to void * the argument to Block _copy ?

Swift ARC and blocks

时间秒杀一切 提交于 2019-12-19 07:21:46
问题 I'm trying a simple example as seen here: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html#//apple_ref/doc/uid/TP40014097-CH20-XID_88 And this is my code. (Ignore other possible code, this is a empty project with this code written inside an empty UIViewcontroller viewDidLoad) dispatch_async(dispatch_get_main_queue()) { [unowned self] in println(self) } I don't understand why it crashes when I run the