automatic-ref-counting

Static library with ARC support linked to non-ARC project causing linker errors

蓝咒 提交于 2019-11-27 19:23:05
I have a non-ARC project that uses an ARC-enabled static library. This is a supported scenario, so that everything works fine. That is, until I run the code on a 4.x device, including the Simulator. In that case the code blows up with the following linker error: dyld: lazy symbol binding failed: Symbol not found: _objc_storeStrong Referenced from: /Users/zoul/Library/Application Support/iPhone Simulator/4.3.2/Applications/…/Demo.app/Demo Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/System/Library/Frameworks/Foundation.framework/Foundation

EXC_BAD_ACCESS message sent to deallocated instance, but I'm using ARC?

六眼飞鱼酱① 提交于 2019-11-27 19:11:13
I've got an app that gets information from a SOAP web service and I want to display the results in a UITableView . I had a previous version of this app and I'm creating a new version to basically clean things up and get rid of a bunch of legacy code that's deprecated and no longer used. In the previous version, this worked well. In the new version, not so much. Basically, the current scenario is returning 3 strings that I'm trying to use as the basis for the data in my UITableView . I'm struggling with this issue because it's so stinkin' hard to track down EXC_BAD_ACCESS errors!

Recommended way to declare delegate properties with ARC

筅森魡賤 提交于 2019-11-27 19:09:55
问题 I used to declare all delegate properties as @property (assign) id<FooDelegate> delegate; I was under the impression that all assign properties should now be weak pointers, is this correct? If I try to declare as: @property (weak) id<FooDelegate> delegate; I get an error while trying to @synthesize (autogenerated weak properties are not supported). What's the best practice in this case? 回答1: Use __unsafe_unretained instead weak for ARC projects targeting iOS 4 and 5. The only difference is

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

南笙酒味 提交于 2019-11-27 19:09:20
问题 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".

Is it necessary to create an autorelease pool under ARC in GCD?

ⅰ亾dé卋堺 提交于 2019-11-27 18:55:33
问题 I have a run loop method for a CAEAGLLayer which uses GCD for serializing access to shared ivars. My drawing code currently is constructed like this: - (void)draw { dispatch_sync(serialDrawingQueue, ^{ @autoreleasepool { [self drawingStart]; [spriteA draw]; [spriteB draw]; [self drawingEnd]; } }); } The draw method is called by a CADisplayLink. Is the @autoreleasepool necessary when I use GCD blocks? 回答1: From the Apple docs: If your block creates more than a few Objective-C objects, you

Files doesn't support the ARC feature, how to deal with

落爺英雄遲暮 提交于 2019-11-27 18:46:24
问题 My project uses the ARC(Automatic Reference Counter), so when i try to import the ASIHTTPRequest library which has 4 classes that used in their implementation the autorelease statement, here is an example: [self setAccessLock:[[[NSRecursiveLock alloc] init] autorelease]]; The error that i got: ARC forbids explicit message send of autorelease What should i do to solve this problem. 回答1: I have got the solution, i needed to add the right flags to the compiler flags for each file which doesn't

Objective-C ARC Error: -fobjc-arc is not supported with fragile abi

半世苍凉 提交于 2019-11-27 18:37:47
问题 I'm having a problem trying to migrate my iPhone app to the new ARC technology. When I try to convert the code, the following error shows up 29 times: Apple LLVM compiler 3.0 Error -fobjc-arc is not supported with fragile abi What does this mean? And more importantly, how can I fix it? Thanks in advance! 回答1: From Apple's developer forums This is an unfortunate bug in Seed 3, where the migrator and simulator aren't working well together. To address this, just switch to a device target, then

SudzC ARC version - objc_msgSend call causes EXC_BAD_ACCESS using 64-bit architecture

拟墨画扇 提交于 2019-11-27 18:36:10
Edit - I've tracked the below issue to a 64-bit vs 32-bit architecture issue... see my posted answer for how I resolved I've used SudzC to generate SOAP code for a web service. They supply you with a sample application, which I was able to use successfully, both on device and simulator. I then started building out my app. I imported the SudzC generated files into a new XCode project using the blank application template (with CoreData and ARC enabled). I got the first SOAP request up and running -- everything works in the simulator -- and then I went to do my first test on a device (iPhone 5S

Is it ever Ok to have a 'strong' reference for a delegate?

眉间皱痕 提交于 2019-11-27 18:35:46
I have a class that retrieves JSON from a URL and returns the data via the protocol/delegate pattern. MRDelegateClass.h #import <Foundation/Foundation.h> @protocol MRDelegateClassProtocol @optional - (void)dataRetrieved:(NSDictionary *)json; - (void)dataFailed:(NSError *)error; @end @interface MRDelegateClass : NSObject @property (strong) id <MRDelegateClassProtocol> delegate; - (void)getJSONData; @end Note that I'm using strong for my delegate property. More about that later... I am trying to write a 'wrapper' class that implements getJSONData in a block-based format.

How do I return a struct value from a runtime-defined class method under ARC?

雨燕双飞 提交于 2019-11-27 18:25:04
问题 I have a class method returning a CGSize and I'd like to call it via the Objective-C runtime functions because I'm given the class and method names as string values. I'm compiling with ARC flags in XCode 4.2. Method signature: +(CGSize)contentSize:(NSString *)text; The first thing I tried was to invoke it with objc_msgSend like this: Class clazz = NSClassFromString(@"someClassName); SEL method = NSSelectorFromString(@"contentSize:"); id result = objc_msgSend(clazz, method, text); This crashed