Questions tagged [strong-references]

Strong references are regular references that are protected from garbage collection, in contrast to weak references.

Strong references are regular references that are protected from garbage collection, in contrast to .

86 questions
1
vote
0 answers

iOS passing object between View Controllers with strong reference

I have a series of VC dedicated to profile editing in a navigation stack. As you go deeper a custom object userProfile is passed in -prepareForSegue. My problem is in this configuration all userProfiles seems to be pointing to a single object, and…
NKorotkov
  • 3,591
  • 1
  • 24
  • 38
1
vote
2 answers

Does NSMutableDictionary keep a strong reference to an object I put in it via 'setValue:forKey:'?

According to Apple's documentation, if I add an object to an NSMutableDictionary via the setObject:forKey: method, the dictionary will keep a strong reference to it. But what about the setValue:forKey: method? The documentation doesn't say anything…
notadam
  • 2,754
  • 2
  • 19
  • 35
1
vote
0 answers

Garbage Collector and four types of references in Java

I am fighting with garbage collector in Java. I want to list all the objects that are reachable from a certain object in three lists, depending on the reference type: strong, soft, weak. No phantom there. I know I need to do it recursively and by…
1
vote
2 answers

Objects reachable by strong or weak references in Java

I am struggling with the garbage collector. I want to list all the objects that are reachable strongly or weakly from a certain object. I know I need to do it recursively, but I can't find a simple way to achieve it. Could you please help me?…
user3572544
  • 189
  • 7
1
vote
2 answers

Weak or strong property declaration when returning value of related view?

I read a Stack Overflow answer that compared strong properties on an object to leashes on a dog. For every declaration made with a strong reference, a new leash is added to the dog. Once every person walking the dog goes home (or once every object…
1
vote
1 answer

Changing @property value of self while executing a block that uses a strong reference to self

I'm working on doing network requests in my app and am using NSBlockOperations in an NSOperationQueue to do this asynchronously. However, I want to be able to cancel these operations if the view controller that called them is deallocated (has been…
1
vote
1 answer

why is my instance garbage collected

I have the following class hierarchy. For some reason, my listener gets garbage collected even though I maintain a strong reference to it. class MyModule { MySubModule submodule = null; MyModule(Channel ch) { submodule = new…
1
vote
2 answers

How is self passed to methods (or how to prevent strong reference cycles)

I'm currently thinking about how to prevent strong reference cycles when using blocks that retain self. The usual way seems to be to just use a weak reference to self: @property (strong, nonatomic) NSOperationQueue *queue; - (void)methodA { …
1
vote
3 answers

View's holding strong references?

Quick question: my ViewController has an IBOutlet for a UILabel would the ViewController's view automatically hold a strong reference to the label? And also, if I programmatically create a UIPopoverController ivar in ViewController and put the…
stumped
  • 3,235
  • 7
  • 43
  • 76
0
votes
1 answer

In Swift, if BOTH the parent and child classes have weak references, then what will happen?

When implementing code in Swift, we always are careful to avoid retaining the cycle, and we avoid using weak or unowned. What will happen if we declare weak for all references, all variables/properties? In short, if we never create strong…
0
votes
2 answers

Java referencing an out-a-scope object

I'm saving the previous value of a Java object. I (almost) understand references are strong, weak, etc. but I can't find an example that classifies my specific situation that is apparently referencing an out-of-scope object. (I've looked at a lot…
Tommy131313
  • 75
  • 1
  • 4
0
votes
0 answers

Strong reference in Date extension Swift

I tried to check my app for memory leaks using Leaks from Instrument. It turns out that the Leaks points out that the memory leak is in on of my extension: Date. The extension function is used inside a View struct in swiftUI to a @Published date:…
Adrian Macarenco
  • 165
  • 2
  • 11
0
votes
1 answer

When I add an item into one recyclerview it gets two

I think it's reference problem. RecyclerViews seem they share items with the same reference. I created two recyclerviews, And I make a list, and I send the list through a method to create another recyclerview. For instance, val myAdapter =…
c-an
  • 3,543
  • 5
  • 35
  • 82
0
votes
0 answers

Turn weak reference to strong

In my code label object is weakly referenced. How can I turn it to strongly referenced one? I got the error 'weakly referenced object no longer exists'. Will increasing the references to that object help? from kivy.app import App from…
Om Behure
  • 27
  • 5
0
votes
1 answer

weakself inside dispatch_async queue(dispatch_get_main_queue(), ^{})

Below code snippet is in objective C __weak MyView *weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.activityIndicatorView stopAnimating]; [weakSelf.activityIndicatorView removeFromSuperview]; …