automatic-ref-counting

Ad Hoc iPhone SIGSEGV crash while Debug on device & simulator works

拥有回忆 提交于 2019-12-22 14:51:03
问题 App crashes immediately after I attempt to login so it can’t a be a watchdog memory issue Reason: _mh_execute_header App crashes upon attempting to make a network request using ASIHTTPRequest. Request never touches server. ASIHTTPRequest: I use -fno-objc-arc to omit ASIHTTPRequest from ARC. I believe that the following call is causing my problems since my call never even touches the server when I make a request. Any help would be greatly appreciated! Call: NSDictionary *response = [

How to programmatically detect automatic reference counting?

为君一笑 提交于 2019-12-22 13:59:35
问题 This might be a silly question, but I just wanted to know. I want my code to detect if ARC is enabled, programmatically. How do I do that? Is there is any flag that I could check? Actually the problem is that, I have written an open-source library. I have used release and retain in it. if some one else uses my library files using ARC enabled, I dont want them to get any errors. how do I achieve this? or is there any possible ways I can provide any tools to compile my library before using it?

Do system object delegates in ARC need to be set to nil?

痞子三分冷 提交于 2019-12-22 11:19:20
问题 An app crashes sometimes with error objc_object::release() . The Apple Developer Technical Support mentioned this: Remember that you should always do something like _tableView.delegate = nil; in your -dealloc methods, even if you are using ARC. For compatibility reasons system objects use unsafe_unretained references to implement delegation, instead of the preferred modern replacement weak . Does that mean that I have to set the delegates of system objects to nil when the view controller is

Xcode ARC conversion tool issue

孤街浪徒 提交于 2019-12-22 09:03:05
问题 I'm running the ARC conversion tool for the first time. I've followed the instructions and dealt with all of the issues/erros in my files that the conversion tool finds before it will actually run. I also have several third party libraries that I've told ARC to skip by unchecking them in the Targets to Convert dialog. After running the tool it shows me a report of all the changed files but no files have been changed. Next I save and try to build the project only to find that I have nearly

dispatch_once call causes crash

时间秒杀一切 提交于 2019-12-22 08:33:20
问题 dispatch_once call causes crash (in simulator) after I've converted my project to ARC. My original problem was that I've got EXC_BAD_ACCESS (in objc_retain call) crash in one of my singleton object's + (SingletonClass)shared { ... dispatch_once(..., ^{}); ... } method exactly one line before the dispatch_once call. Based on loggings, and breakpoints my code have not run into the dispatch_once call's block. I didn't know the reason, so I've just commented out the dispatch_once call. My app

id array member instance under ARC

坚强是说给别人听的谎言 提交于 2019-12-22 05:59:32
问题 I want to write something like this: @interface Foo{ __strong id idArray[]; } @end But the compiler complains about it: Field has incomplete type '__strong id []'. How can I create an id array member instance under ARC? And how do I init that array? Using malloc? new[]? I don't want to use NSArray because I'm converting a large library to ARC and that will cause a lot of work. 回答1: If you want to allocate dynamically the array, use pointer type of id __strong. @interface Foo { id __strong

How to require ARC in a class?

好久不见. 提交于 2019-12-22 04:27:12
问题 I have an app with both ARC code and non-ARC code. The compiler will catch when I try to compile non-ARC code as ARC. How do I cause a compile time error/notice when my ARC code is erroneously compiled without ARC? Obviously, the code will compile. It will just leak. The static analyzer will catch the problem. I would rather find a way to leave a pragma or define in my ARC code. The following is defined by Apple in objc-api.h : /* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */ #if

iOS: Block property directly set crashes when accessed

a 夏天 提交于 2019-12-22 04:16:23
问题 Consider the following code: @interface ClassA : NSObject @property (nonatomic, copy) void(^blockCopy)(); @end @implementation ClassA @synthesize blockCopy; - (void)giveBlock:(void(^)())inBlock { blockCopy = inBlock; } @end Then use it in a class which has a strong property of type ClassA called someA : self.someA = [[ClassA alloc] init]; [self.someA giveBlock:^{ NSLog(@"self = %@", self); }]; dispatch_async(dispatch_get_main_queue(), ^{ self.someA.blockCopy(); self.someA = nil; }); If I run

Can a custom xcode template partially and selectively enable ARC (Automatic Reference Counting)?

别等时光非礼了梦想. 提交于 2019-12-21 22:20:48
问题 Problem: A library I use won't support ARC (Automatic Reference Counting). Background (for those unfamiliar to ARC): http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html Manual Solution: Add the -fno-objc-arc option for each implementation file of the library, and otherwise use ARC normally in my application code. Observation: The following template file can be copied and most likely be used to either turn ARC completely ON or OFF (without adding

ARC does not dealloc when pointer is set to nil (using factory methods)

馋奶兔 提交于 2019-12-21 21:36:28
问题 Edit: Problem defined below actually occurred with this code: int main(int argc, const char * argv[]) { @autoreleasepool { XYZPerson *myPerson = [XYZPerson person]; myPerson = nil; NSLog(@"The end."); } } The method 'person' is a factory method. I have the following code: int main(int argc, const char * argv[]) { @autoreleasepool { XYZPerson *myPerson = [[XYZPerson alloc] init]; myPerson = nil; NSLog(@"The end."); } } XYZPerson overrides dealloc method so that it prints out something with