automatic-ref-counting Questions

19

Solved

I'd like to store an array of weak references in Swift. The array itself should not be a weak reference - its elements should be. I think Cocoa NSPointerArray offers a non-typesafe version of this....
Microsporophyll asked 9/6, 2014 at 19:34

8

Solved

Swift has: Strong References Weak References Unowned References How is an unowned reference different from a weak reference? When is it safe to use an unowned reference? Are unowned reference...

4

Solved

This question is similar to ios NSError types but the solution described there didn't work and I believe it isn't quite what I need. I have a method that takes performs an asynchronous call and th...
Bethune asked 2/1, 2015 at 14:55

12

Solved

In WWDC 2014 session 403 Intermediate Swift and transcript, there was the following slide The speaker said in that case, if we don't use [unowned self] there, it will be a memory leak. Does it m...
Mexicali asked 20/6, 2014 at 5:11

1

I am trying to return a struct containing reference to a shared mutex: struct Test<'a> { mutex: Arc<Mutex<()>>, guard: &'a MutexGuard<'a, ()>, } impl<'a> Test&l...
Lukewarm asked 21/1, 2022 at 19:42

5

Solved

Apple's Swift Programming Language Guide mentions the capture specifiers unowned(safe) and unowned(unsafe), in addition to weak and unowned. I (think I) understand the differences between weak an...
Mooring asked 24/10, 2014 at 18:19

4

Solved

I have the following test case: I expect deinit to be called at program termination but it never is. I'm new to Swift but would not think this is expected behaviour. (this is not in a playground) ...
Paralogism asked 23/2, 2018 at 15:9

4

Solved

So I'm using ARC in my project and when I add an AVPlayerLayer it works just fine and dandy, but when I pop the UIViewController from my UINavigationItem the video continues to play in the backgrou...
Aletheaalethia asked 9/11, 2011 at 23:16

14

Solved

We use auto layout constraints selectively, primarily to position labels in relation to editable field elements (UITextView, UITextField, typically). However, since implementing auto layout for the...
Humberto asked 16/7, 2013 at 22:59

13

In a certain (consistent) point when my app is running, I consistently get the xcode error message Terminated due to memory error. I cannot find the code causing the error, but I can tell wha...
Tamikotamil asked 5/10, 2013 at 23:29

3

Solved

While using lazy initialisers, is there a chance of having retain cycles? In a blog post and many other places [unowned self] is seen class Person { var name: String lazy var personalizedGree...

4

Solved

I'm trying to complete the puzzle. __strong is the default for all Objective-C retainable object pointers like NSObject, NSString, etc.. It's a strong reference. ARC balances it with a -release at...
Burstone asked 14/1, 2012 at 11:52

2

Solved

I have a view controller that is never released once its parent view controller is removed from the view hierarchy and released. Every instance of it within the memory graph looks the same in that ...
Drewdrewett asked 10/12, 2020 at 19:2

1

Since Apple's API is not opened source nor it is mentioned in the documentation, when writing in Swift, we have no way, to know whether the returned object is an autorelease objective-c object. Hen...
Kashmir asked 18/8, 2021 at 4:35

10

Solved

I'm using an NSTimer like this: timer = [NSTimer scheduledTimerWithTimeInterval:30.0f target:self selector:@selector(tick) userInfo:nil repeats:YES]; Of course, NSTimer retains the target which ...
Croaker asked 29/5, 2013 at 18:54

3

Solved

Today, I have update my xCode to 4.2 version, And I want to disable the ARC, I also search with the google. but can't fix my problem. According the search results, In the target setting, I can't fi...
Stalwart asked 20/10, 2011 at 13:55

4

Solved

I am confused with Apple material. In 3 ways we manage the memory, they are : automatic referance counting. manual reference counting. garbage colletion. My doubt is what is the difference ...
Tetramethyldiarsine asked 2/2, 2012 at 9:50

8

Solved

For the most part with ARC (Automatic Reference Counting), we don't need to think about memory management at all with Objective-C objects. It is not permitted to create NSAutoreleasePools anymore, ...

1

Solved

I'm doing a performance test to try to measure the rendering performance of an important NSOutlineView in my Mac app. In the process, I'm looping several times, creating the view, embedding it in a...
Inclinometer asked 26/4, 2021 at 22:58

4

Solved

I'd like to write an iOS unit test for a dealloc method that (basically) removes the object as the delegate of another object. - (void) dealloc { someObject.delegate = nil; } However I can't ca...
Allergen asked 3/12, 2011 at 18:0

1

Solved

I was using the onChange(of:perform:) SwiftUI modifier. I then wanted to get the old value, to compare it with the new value. I read the documentation, which says: The previous value may be captur...
Kisor asked 3/10, 2020 at 21:17

2

Solved

I'm trying to figure out how the ownership works with the function CVMetalTextureGetTexture: CVMetalTextureRef textureRef; // ... textureRef is created id<MTLTexture> texture = CVMetalTextur...

10

Solved

I'm working on an iOS application that needs to play some sounds using the AVFoundation framework. The workspace structure in Xcode 4 contains two projects: Workspace The application itself (mai...
Balustrade asked 4/11, 2011 at 23:9

3

Solved

If I have a closure passed to a function like this: someFunctionWithTrailingClosure { [weak self] in anotherFunctionWithTrailingClosure { [weak self] in self?.doSomething() } } If I declar...

3

Solved

I have a weak NSPointerArray with some NSObject that has been released. Before calling compact what I see is: (lldb) po [currentArray count] 1 (lldb) po [currentArray pointerAtIndex:0] <nil>...
Bedizen asked 9/7, 2015 at 15:43

© 2022 - 2024 — McMap. All rights reserved.