automatic-ref-counting

iOS memory warning sent to deallocated UIViewController

断了今生、忘了曾经 提交于 2019-12-11 03:52:42
问题 I have strange behavior. My application being launched with UINavigationController . If I push view controller ANavigationController , go back and simulate memory warning everything works good. If I push the same view controller ( ANavigationController ) the same way, go back and simulate memory warning - application crashes with error: [ANavigationController retain] : message sent to deallocated instance. While debugging this I've printed addresses of pushed controller and deallocated one:

disabling ARC for .h files iphonesdk

心已入冬 提交于 2019-12-11 03:50:37
问题 My projects uses ARC and I want to use GDATA api which is not ARC Compatible. I know how to disable ARC for single file(by adding the -fno-objc-arc compiler flag for those files). But in GDataObject.h file there is a structure defenition as typedef struct GDataDescriptionRecord { NSString *label; NSString *keyPath; enum GDataDescRecTypes reportType; } GDataDescriptionRecord; It causes an error like ARC forbids object in struct or union How can I avoid this problem. Is there any ARC compatible

Does the Core Foundation objects are automatically released by ARC or do we need manual memory management?

自古美人都是妖i 提交于 2019-12-11 03:33:52
问题 In my code am creating a Core Foundation object, and from the apple documentation i came to know that "The life span of a Core Foundation object is determined by its reference count" https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Articles/lifecycle.html So I highly doubt that whether the core foundation objects are released by ARC or do we need to release by writing CFRelease(myobject) Am using Xcode 6.4,and presently in my code am not using any

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

坚强是说给别人听的谎言 提交于 2019-12-11 03:27:56
问题 I'm writing a sandboxed ARC app with a view-based NSTableView that accepts dragged-and-dropped files ( NSURL s). I ran into some significant strangeness in the following NSTableViewDelegate method: - (NSView *)tableView:(NSTableView *)tv viewForTableColumn:(NSTableColumn *)tc row:(NSInteger)row { // `files' is an NSMutableArray* ivar containing NSURLs // that have been dropped into this table NSURL *url = [files objectAtIndex:row]; NSString *fileName = [url lastPathComponent]; NSImage *icon =

Objective-C ARC - does a method retain 'self'? [duplicate]

岁酱吖の 提交于 2019-12-11 03:12:57
问题 This question already has answers here : Is “self” weak within a method in ARC? (2 answers) Closed 4 years ago . Is this a safe thing to do? __weak typeof (self) welf = self; dispatch_async(dispatch_get_main_queue(), ^{ [welf doStuff]; }) .... -(void)doStuff { [_member1 someMethod]; .... [_member2 someMethodWithParam:_someCArray[1];]; } As far as I understand ARC, the actual call to [welf doStuff] should be fine, as welf will either be valid (and the method call will proceed), or it will be

Using Objective-C's method_invoke to call a void method under ARC

倖福魔咒の 提交于 2019-12-11 02:45:20
问题 On iOS, I'm attempting to use the method_invoke function from the Objective-C runtime (reference) in order to call an Objective-C method that is declared with a return type of void . This works fine in non-ARC code, but with ARC enabled, I get a crash after the invocation of the method in objc_retain . I think what's going on is that the compiler notices method_invoke 's return type of id , and attempts to retain the value returned by method_invoke (note that method_invoke is meant to return

Why is Objective-C ARC deallocation dependent on whether an object was created in function?

风流意气都作罢 提交于 2019-12-11 02:37:58
问题 I'm learning about ARC memory management and ran across something that doesn't make sense to me. In the example code below, an object that is allocated locally in main() gets deallocated when its pointer is assigned to nil, as I would expect. But if the same type of object is allocated in another function, and a pointer to it is defined in main(), and that pointer is set to nil, the object does not get deallocated until main function exits. That is mysterious to me. In the code below, two

Why is object not dealloc'ed when using ARC + NSZombieEnabled

末鹿安然 提交于 2019-12-11 02:36:42
问题 I converted my app to ARC and noticed that an object alloc'ed in one of my view controllers was not being dealloc'ed when that view controller was dealloc'ed. It took a while to figure out why. I have Enable Zombie Objects on for my project while debugging and this turned out to be the cause. Consider the following app logic: 1) Users invokes action in RootViewController that causes a SecondaryViewController to be created and presented via presentModalViewController:animated . 2)

Add [unowned self] to the closure argument Swift

孤者浪人 提交于 2019-12-11 01:18:45
问题 I have a function with a completion handler, returning one parameter or more. In a client, when executing a completion handler, I'd like to have an unowned reference to self , as well as having access to the parameter passed. Here is the Playground example illustrating the issue and the goal I'm trying to achieve. import UIKit struct Struct { func function(completion: (String) -> ()) { completion("Boom!") } func noArgumentsFunction(completion: () -> Void) { completion() } } class Class2 {

ARC delegate memory management

ぐ巨炮叔叔 提交于 2019-12-11 00:48:09
问题 In Apple's docs it says You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC. Does this include UIKit and Framework delegates, for example, the parent of a UIPageViewController has the delegate UIPageViewControllerDelegate - does this have to be