automatic-ref-counting

What's the equivalent of '[[something retain] autorelease]' in ARC?

落爺英雄遲暮 提交于 2019-12-10 04:29:15
问题 What's the equivalent of [[something retain] autorelease] in ARC? I have a problem where a class DBRequest calls my delegate to signify completion. My delegate then sets the DBRequest instance to nil, which dealloc's it. But then when the stack pops out of my delegate and jumps back to the DBRequest, it of course then crashes. If I wasn't in ARC, in my delegate I'd simply do [[theDbRequest retain] autorelease] before releasing my reference to it, so that it'd survive long enough until the

Why doesn't ARC free memory when using [NSDate date] but works fine using [[NSDate alloc] init]?

ぐ巨炮叔叔 提交于 2019-12-10 03:26:29
问题 I've written some Objective-C application that seems to work fine, except for an ever-growing memory footprint. I'm using ARC under the last version of Xcode 4.6.2. My system is 10.7.5. I'm very new to Objective-C and need some help figuring out what's going on with my memory. I've narrowed down the problem to explaining why the following basic piece of code behaves like it does. This code is added in the vanilla Cocoa-based application template that Xcode gives (ARC enabled). Case A - (void

Xcode Convert to ARC, Create universal binary fails with error of “can't figure out the architecture type of”

五迷三道 提交于 2019-12-10 02:59:09
问题 I'm attempting to convert an iOS (pure Objective-C) project to ARC. The conversion fails at the octest target CreateUniversalBinary stage with the following error. The project and target architecture build settings look correct to me so I am struggling to understand why this is failing: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo: can't figure out the architecture type of: /Users/andybowskill/Library/Developer/Xcode/DerivedData/Make-Up_Kit

What's the right way to set an NSError outparam from inside an autoreleasepool block?

拟墨画扇 提交于 2019-12-10 02:32:06
问题 I have a method like this: - (void)processAThing:(id)thing error:(NSError * __autoreleasing *)error { @autoreleasepool { // Start processing. // Find some partway through error.. if (error) { *error = [NSError errorWithDomain...]; return NO; } // More processing. } } This is broken and crashes, because the NSError is autoreleased, and when the return happens, the pool is drained, so the thing that the caller gets is now bogus. I know I could significantly redesign the method so I collect all

How to find the real cause of memory warning and how to resolve in iOS app

╄→尐↘猪︶ㄣ 提交于 2019-12-10 02:23:40
问题 I have go through many posts related memory management, ARC , memory management techniques like autoreleasepool and using instruments tool to detect which code is causing memory warning but in my case I am not able to figure out the exact cause. Basic details which you must know about the app: We have developed an iPad app. In that we have to use more then 2000 images in some case, so when my app launch we do not want to show them placeholder image (client requirement).so to achieve this, we

EXC_BAD_ACCESS (SIGSEGV)

。_饼干妹妹 提交于 2019-12-10 02:21:47
问题 I got this crash report from a remote user, but I cannot find any useful tip to resolve this issue, may be it's a retain problem but I cannot understand why because of I'm using ARC. Very small number of users are issuing this problem. I've tried all things both on simulator and on device (iPhone 4s) without any crash occurs... If I was able to crash on my device it will be very simple to find out what the problem is. Somebody knows how to fix this issue? Incident Identifier: F30F9C75-0FE3

Does Objective-C forbid use of structs?

偶尔善良 提交于 2019-12-09 16:43:17
问题 I'm new to Objective C I tried using a simple struct and got arc forbids objective-c objects in struct Looking up ARC, it looks like this is the specification that defines Objective C syntaxt - is that correct? Secondly, how do I go about using struct if it's not allowed? Thank you! Edit: Some code as a sample @implementation Cities { // The goal is to have a struct that holds information about a city, // like when a person started and ended living there. // I was trying to make this struct

How can one turn ARC off for specific file

烂漫一生 提交于 2019-12-09 14:48:12
问题 I know I am supposed to add the compiler flag -fno-objc-arc to the compile sources in XCode 4 to accomplish this. But it isn't working. Even with the added flag I am still getting errors in my KeychainItemWrapper.m file claiming I need to use __bridge for C pointers. My project is ARC safe, but the Apple provided reference for interacting with the Keychain is not. I would like to just disable ARC for that single file. What else am I missing here? 回答1: I've had this happen more than once for

In arc what happens when you don't synthesize

丶灬走出姿态 提交于 2019-12-09 10:40:27
问题 In an iOS ARC enabled project, what happens when I don't synthesize a property, since retain/release are disallowed? @interface SomeClass : NSObject { NSMutableArray* _pieces; } @end What are the memory semantics of the iVar _pieces in this case? Say I set it using, _pieces = whatever . Is _pieces set to nil when the instance of my SomeClass is deallocated? Is _pieces stored as a weak reference? If all other objects that have retained _pieces release it, will it be null when I attempt to

Xcode 4.6 ARC Warning for Game Center Authentication

▼魔方 西西 提交于 2019-12-09 09:08:57
问题 This is a new compiler warning that only showed up when I updated XCode to 4.6. My code is lifted directly from Apple's documentation (this is my iOS 6 code btw). GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer]; localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error) { [self setLastError:error]; if(localPlayer.authenticated){ Warning--Capturing 'localPlayer' strongly in this block is likely to lead to a retain cycle 回答1: The issue is that the localPlayer