automatic-ref-counting Questions
8
Is there a mechanism which would allow an object to know that a zeroing weak reference turned nil?
For example I have a property
@property (nonatomic, weak) MyClass *theObject;
when theObject d...
Yetty asked 13/10, 2013 at 10:22
5
Solved
I have a Swift class that needs to store a table of its own methods. Unfortunately this is causing a reference cycle, because its table retains references to self via the methods it stores.
Exampl...
Epilate asked 1/9, 2014 at 22:59
4
Solved
In Swift, I notice there is no @autoreleasepool{} construct, although Swift does use ARC. What is the proper way to manage an autoreleasepool in Swift, or has it been removed for some reason?
Beauregard asked 10/6, 2014 at 22:44
10
Solved
Lets say we have three objects: a grandparent, parent and child. The grandparent retains the parent, the parent retains the child and the child retains the parent. The grandparent releases the pare...
Deforest asked 10/11, 2013 at 16:41
1
In swift class type has method deinit() in which we can define that instance of class will be removed from memory. How we can know for struct that it will be removed from memory?
For example,
str...
Spires asked 20/10, 2017 at 4:52
4
Solved
If I use malloc along with Automatic Reference Counting, do I still have to manually free the memory?
int a[100];
int *b = malloc(sizeof(int) * 100);
free(b);
Nepos asked 7/5, 2012 at 2:37
4
Solved
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
...
Baklava asked 27/6, 2013 at 16:31
6
We have some code today that takes an NSArray and passes it as a argument list to -[NSString initWithFormat:arguments] and we're trying to get this to work with ARC. Here's the code were using
NSS...
Dovecote asked 25/11, 2011 at 19:17
1
What happens if I smuggle self out of my deinit, by assigning it to some external strong reference? This code below is clearly not well formed:
class C: CustomStringConvertible {
let s = "abc"
...
Wriest asked 12/9, 2019 at 18:13
1
Solved
I have two reference counted classes that hold reference to each other instances. One of those references is marked as [weak] to prevent creating strong reference cycle.
type
TFoo = class(TInter...
Preceding asked 5/8, 2019 at 19:29
5
Solved
In Objective-C in non-trivial blocks I noticed usage of weakSelf/strongSelf.
What is the correct way of usage strongSelf in Swift?
Something like:
if let strongSelf = self {
strongSelf.doSomethi...
Downhaul asked 16/7, 2015 at 12:41
1
Solved
This is allowed in Swift 5.0:
class Person {
unowned var child: Person?
}
This is supported by this release notes:
unowned and unowned(unsafe) variables now support Optional types.
(473267...
Giorgia asked 24/2, 2019 at 14:28
1
Is it true that ARC keeps a count of unowned references to an object?
So, if the strong reference count of an object reaches 0 and the unowned reference count of that object is > 0 the object is d...
Cherokee asked 22/2, 2019 at 23:47
7
Solved
How can I avoid this warning in xcode. Here is the code snippet:
[player(AVPlayer object) addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(0.1, 100)
queue:nil usingBlock:^(CMTime time) {
...
Scyros asked 28/1, 2013 at 6:30
2
Class is a struct pointer, is it a object type or scalar, which I guess is the key to decide to use strong/weak or assign?
Operator asked 10/12, 2018 at 5:29
8
Solved
There are two new memory management attributes for properties introduced by ARC, strong and weak.
Apart from copy, which is obviously something completely different, are there any differences betw...
Scathe asked 19/1, 2012 at 14:27
4
Solved
ARC forbids Objective-C objects in structs or unions despite marking the file -fno-objc-arc?
Why is this so?
I had the assumption that if you mark it -fno-objc-arc you don't have this restriction....
Causality asked 11/11, 2011 at 11:9
1
I have a class A that stores a optional weak variable to other object, that is a subclass of A. Sometimes when I store something in this variable I get a leak - this happens rarely, but it does. I'...
Electroform asked 14/7, 2018 at 14:55
10
Solved
I'm currently using the iOS 5 SDK trying to develop my app.
I'm trying to make an NSString a property, and then to synthesize it in the .m file (I have done this before with no issues). Now, I came...
Scyphozoan asked 13/6, 2011 at 7:0
3
Solved
I have some Core Data functionality that was working fine until some recent (seemingly unrelated) changes were made. Now I'm getting problems where all the attributes belonging to a particular NSMa...
Riot asked 26/8, 2011 at 1:27
18
Solved
I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile right now. I recall hearin...
Woollyheaded asked 11/7, 2011 at 5:21
5
Solved
In the Mac and iOS platforms, memory leaks are often caused by unreleased pointers. Traditionally, it has always been of utmost importance to check your allocs, copies and retains to make sure each...
Deprave asked 7/6, 2011 at 3:8
1
Xcode 9.3 newly recommends setting CLANG_ENABLE_OBJC_WEAK to YES for all Objective-C projects. Can someone explain what this setting will mean for a non-ARC app?
Hypersensitive asked 2/4, 2018 at 20:29
5
Solved
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 ...
Auria asked 26/11, 2014 at 15:12
5
Solved
I've read posts about strong/weak self to break retain cycles but I am still confused as to how they work. I understand the use of __weak typeof(self) weakSelf = self to create a weak reference to ...
Camboose asked 8/7, 2015 at 2:22
© 2022 - 2024 — McMap. All rights reserved.