automatic-ref-counting

What property should I use for a Dispatch Queue after ARC?

女生的网名这么多〃 提交于 2019-11-27 17:59:18
I maintain a dispatch queue as a property with my view controller. I create this queue once in my view controller's init method, and reuse a few times for some background tasks. Before ARC, I was doing this: @property (nonatomic, assign) dispatch_queue_t filterMainQueue; And in init: if (filterMainQueue == nil) { filterMainQueue = dispatch_queue_create("com.myQueue.CJFilterMainQueue", NULL); } But after ARC, I'm not sure if this should still be "assign", or should it be "strong" or "weak". The ARC convertor script didn't change anything but I'm not sure if a subtle bug is coming from the fact

Does cocos2d support ARC?

∥☆過路亽.° 提交于 2019-11-27 17:51:01
问题 I am using Xcode 4.2 and building a game for iphone (from iOS 3.0 - 5.0). Does cocos2d support ARC? What modifications needs to be made to convert code written in previous versions? If I use the strong and weak keywords for variables and set compiler to LLVM GCC 4.2, what will be the results? Is it a necessity to change compiler to 3.0 to support ARC? 回答1: Cocos2d v1.1 and v2.0 are compatible with ARC. However, the cocos2d code itself does not use ARC and there are no templates provided by

Recursive Blocks in Objective-C leaking in ARC

谁说我不能喝 提交于 2019-11-27 17:50:43
问题 So I'm using recursive blocks. I understand that for a block to be recursive it needs to be preceded by the __block keyword, and it must be copied so it can be put on the heap. However, when I do this, it is showing up as a leak in Instruments. Does anybody know why or how I can get around it? Please note in the code below I've got references to a lot of other blocks, but none of them are recursive. __block NSDecimalNumber *(^ProcessElementStack)(LinkedList *, NSString *) = [^NSDecimalNumber

Singleton with ARC

天涯浪子 提交于 2019-11-27 17:45:24
My question is the following: I have a singleton type object (I'm using ARC) that has this code in the implementation file +(id)sharedInstance { static DataManager *sharedInstance; if (sharedInstance == nil) { sharedInstance = [[DataManager alloc] init]; } return sharedInstance; } +(NSManagedObjectContext *)getManagedContext { AppDelegate *applicationDelegate =(AppDelegate *)[[UIApplication sharedApplication] delegate]; return [applicationDelegate managedObjectContext]; } +(void)saveContext:(NSManagedObjectContext *)context { NSError *error; if (![context save:&error]) { NSLog(@"Whoops, couldn

What are the advantages and disadvantages of using ARC? [closed]

怎甘沉沦 提交于 2019-11-27 17:42:12
What are the advantages and disadvantages of using the new automatic reference counting (ARC) memory management style in an iOS project? Can you choose not to use ARC when developing with the iOS 5.0 SDK? Do you recommend ARC or manual reference counting (MRC) for a new project? Will an application using ARC be able to run on older OS versions than iOS 5.0? justin What are the advantages and disadvantages of using the new automatic reference counting (ARC) memory management style in an iOS project? An ARC program's execution is nearly identical to well written MRC. That is, the behavioral

Correct bridging for ARC?

六眼飞鱼酱① 提交于 2019-11-27 17:41:59
I have a category class for NSString. @implementation NSString (URLEncode) - (NSString *)URLEncodedString { __autoreleasing NSString *encodedString; NSString *originalString = (NSString *)self; encodedString = (__bridge_transfer NSString * ) CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef)originalString, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8); return encodedString; } Am I using the correct bridge transfers for ARC and the new LLVM? The original code: - (NSString *)URLEncodedString NSString *encodedString = (NSString *

Cocoa blocks as strong pointers vs copy

这一生的挚爱 提交于 2019-11-27 17:38:06
I did work several times with blocks as with pointers to which i had strong reference I heard that you should use copy, but what is the implication in working with blocks as pointers and not with the raw object? I never got a complain from the compiler, that i should not use @property (nonatomic, strong) MyBlock block; but should use @property (nonatomic, copy) MyBlock block; as far as i know, the block is just an object, so why to preferrer copy anyway? CRD Short Answer The answer is it is historical, you are completely correct that in current ARC code there is no need to use copy and a

Is self.iVar necessary for strong properties with ARC?

丶灬走出姿态 提交于 2019-11-27 17:28:14
问题 If I declare a property strong, like so: @property (strong, nonatomic) UIView *iVar; When I'm setting it, does it matter if I do iVar = ... or self.iVar = ... ? It seems that with ARC, they do the same thing. If I only declare the instance variable (not the @property), e.g., BOOL selected , does that mean it's inferred to be __unsafe_unretained (since there's no property specifying it to be strong), or must I explicitly specify that? It seems like I may have answered my own questions above in

NSMakeCollectable and ARC doesn't work

家住魔仙堡 提交于 2019-11-27 17:16:34
问题 I'm trying to convert my old project to ARC. I have a function which creates UUIDs, but apparently this is no longer supported when using ARC: NSString *uuid = nil; CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault); if (theUUID) { uuid = NSMakeCollectable(CFUUIDCreateString(kCFAllocatorDefault, theUUID)); //[uuid autorelease]; CFRelease(theUUID); } I get the compiler error (when trying to convert): 'NSMakeCollectable' is unavailable: not available in automatic reference counting mode. So

UIPopovercontroller dealloc reached while popover is still visible

吃可爱长大的小学妹 提交于 2019-11-27 17:16:20
I assure you that I did look for an answer in SO for my question but none of them were helpful. Here I got a simple code that should present a UIImagePickerController within a UIPopoverController : -(void)takePicture:(id)sender{ UIImagePickerController *picker=[[UIImagePickerController alloc] init]; picker.delegate=self; picker.sourceType=UIImagePickerControllerSourceTypeCamera; picker.allowsEditing=YES; UIPopoverController *poc=[[UIPopoverController alloc] initWithContentViewController:picker]; [poc presentPopoverFromBarButtonItem:bbItem permittedArrowDirections:UIPopoverArrowDirectionAny