Questions tagged [automatic-ref-counting]

Automatic Reference Counting (ARC) is a compiler feature that provides automatic memory management of Objective-C and Swift objects.

Automatic Reference Counting (ARC) is a technology introduced in LLVM 3.0 (which ships with Xcode 4.2) for managing memory in Objective-C. Swift also uses ARC. This method removes the need for much of the code previously required for manual memory management (MRR) of objects in Objective-C (such as manually calling release) and introduces new memory management qualifiers (namely strong and weak). ARC is a compile-time feature that transparently incorporates the appropriate reference-counting memory management calls into the final application. Like manual reference counting, there is no run-time garbage collection.

References:

See Also

  • For the Arc programming language, see arc-lisp.
3809 questions
2
votes
1 answer

Calling makeViewWithIdentifier:owner: causes ARC to re-create ivar

I'm writing a sandboxed ARC app with a view-based NSTableView that accepts dragged-and-dropped files (NSURLs). I ran into some significant strangeness in the following NSTableViewDelegate method: - (NSView *)tableView:(NSTableView *)tv …
Richard
  • 3,316
  • 30
  • 41
2
votes
5 answers

ARC and __unsafe_unretained

I think I have a pretty good understanding of ARC and the proper use cases for selecting an appropriate lifetime qualifiers (__strong, __weak, __unsafe_unretained, and __autoreleasing). However, in my testing, I've found one example that doesn't…
J Shapiro
  • 3,861
  • 1
  • 19
  • 29
2
votes
5 answers

ARC cast - Hacking objc objects memory

This piece of code used to compile fine in non-ARC: int *privateObjMemory = (int *)[myObject performSelector:@selector(privateMethod)]; now I am in ARC I get: Cast of an Objective-C pointer to 'int *' is disallowed with ARC How could I fix this?…
nacho4d
  • 43,720
  • 45
  • 157
  • 240
2
votes
1 answer

Receiver type ‘X’ for instance message is a forward declaration CGPOINT, IOS

I have seen similar questions for same error.After refactoring code to Arc I get Receiver type ‘CGPointObject’ for instance message is a forward declaration error . And it is recommended that move @class method to .h file and #import .h file of…
Mord Fustang
  • 1,523
  • 4
  • 40
  • 71
2
votes
1 answer

What are ARC implications for using 'init' in non-initializer method names for singleton only classes

So it has been my understanding that using init within a method name is not advisable if that method doesn't actualize initialize a new instance of the object. However, what is the case for a singleton type class? If I do something like this: +…
Andrew Lauer Barinov
  • 5,694
  • 10
  • 59
  • 83
2
votes
1 answer

Is there a way of tracking whats still pointing to a object?

I'v been trying to track down why a block of memory that isn't released. I can see it alloc but when I leave the view and return it's reallocated. It's allocating a nib then using the view. Is there a way of tracking whats still pointing to the…
Benjamin
  • 663
  • 8
  • 23
2
votes
2 answers

Is it really a good option to use ARC for IOS 4.0 where there is no weak property

I am working on a ARC based project. My project is targeted IOS 4.3. Since there is no weak pointer for the version < IOS 5.0, I have to use unsafe_unretained which may cause dangling pointers. Now I am thinking, is it really, good option to use ARC…
Raj
  • 1,119
  • 1
  • 15
  • 32
2
votes
2 answers

Are the objective C selectors dealloc and release in still in use as of iOS 6?

I'm new iOS development. Do I still need to release my properties in dealloc in iOS 6? If not, how are my retained properties released? Is it done automatically? Need some guidance on this. Sorry if this is a stupid question.. For example, when i do…
lakshmen
  • 28,346
  • 66
  • 178
  • 276
2
votes
2 answers

Are local static variables released on dealloc in Objective-C / ARC?

I have a factory which handles singletons as follows @implementation MyFactory - (AudioEngine *)theAudioEngine { static AudioEngine *ae = nil; if (ae == nil) { ae = [[AudioEngine] alloc] init]; } return ae; } @end Are…
Hari Honor
  • 8,677
  • 8
  • 51
  • 54
2
votes
0 answers

iOS6 + ARC + cocos2D + UIKit : message sent to deallocated instance

I am currently experiencing some strange behavior when mixing cocos2d with UIKit. I've been tracking the zombies and it's always an overrelease that triggers the crashes. Now I know this is vague so I'll sketch a scenario where this happens in…
ekinsol
  • 501
  • 1
  • 3
  • 9
2
votes
5 answers

To use Automatic Reference Counting or not to use

Im currently learning Objective C, and so far Ive been using Automatic Reference Counting with all my projects. However after speaking to some colleagues, and after looking at some forums online, Ive noticed a trend to turn off Automatic Reference…
Jimmery
  • 9,783
  • 25
  • 83
  • 157
2
votes
3 answers

How can clang warn me if I fail to initialize a variable while using ARC?

I forgot to initialize a local variable, and I got no warning when I used it. Since I'm using ARC, the variable was initialized to nil, so no harm was done, but I still want a warning when I used an uninitialized value. If I disable ARC, I get the…
Heath Borders
  • 30,998
  • 16
  • 147
  • 256
2
votes
2 answers

ARC is releasing calloc'ed memory?

Something strange is going on in my code. Basically im doing the network stream application that transfers some data into ring buffer memory on iOS and then afterwards read the memory. I was getting EXC_BAD_ACCESS after some undetermined amount of…
Gossamer
  • 309
  • 2
  • 16
2
votes
1 answer

iOS: memory allocation of navigation controller in Stroyboard (by using pushviewcontroller method)

I currently find a really wired problem when I using the statement with stroyboard SomeViewController *homeView = [self.storyboard instantiateViewControllerWithIdentifier:@"someID"]; [self.navigationController pushViewController:homeView…
2
votes
1 answer

Retain cycle with CCAction and CCCallFunc/CCCallBlock

I'm in the final stages of releasing my first game, and after running Instruments:Leaks & Allocations, I see that I have a leak in my code caused by a retain cycle. I am using Cocos2d 2.0, and compiling my app with ARC, and I should mention that I…
Brian Stewart
  • 9,157
  • 11
  • 54
  • 66
1 2 3
99
100