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

Turns out, I’ve written some serious nonsense If zombies worked like I originally wrote, turning on zombies would directly lead to innumerable false positives… There is some isa-swizzling going on, probably in _objc_rootRelease, so any override of dealloc should still be called with zombies enabled. The only thing that won’t happen with zombies is the … Read more

Did the Target-Action design pattern became bad practice under ARC?

The problem with performSelector is that ARC doesn’t know what the selector which will performed, does. Consider the following: id anotherObject1 = [someObject performSelector:@selector(copy)]; id anotherObject2 = [someObject performSelector:@selector(giveMeAnotherNonRetainedObject)]; Now, how can ARC know that the first returns an object with a retain count of 1 but the second returns an object which is autoreleased? … Read more

ARC and CFRelease?

You can’t release mimeType because you don’t own it. You didn’t transfer ownership with the __bridge cast. You should be releasing uti since you have created it. You should also release extension since you created it as well, but that will likely cause issues with ext. Instead, transfer ownership to ext. I’d suggest the following: … Read more

Displaying a Cocoa Window as a Sheet in Xcode 4 (OSX 10.7.2) with ARC

Tutorial for Xcode 4 Create new project and add the following to AppDelegate.h and AppDelegate.m. AppDelegate.h #import <Cocoa/Cocoa.h> @interface AppDelegate : NSObject <NSApplicationDelegate> { IBOutlet NSPanel *theSheet; } @property (assign) IBOutlet NSWindow *window; @end AppDelegate.m #import “AppDelegate.h” @implementation AppDelegate @synthesize window = _window; – (IBAction) showTheSheet:(id)sender { [NSApp beginSheet:theSheet modalForWindow:(NSWindow *)_window modalDelegate:self didEndSelector:nil contextInfo:nil]; } … Read more

IBOutlet and viewDidUnload under ARC

Just doing a bit of research… As I understand it, weak is similar to assign, in that they’re both weak references. However, assign does not create a zeroing reference. i.e. if the object in question is destroyed, and you access that property, you WILL get a BAD_ACCESS_EXCEPTION. Weak properties are automatically zeroed (= nil) when … Read more

Find where object is retained with ARC

To track growth of an application, Heapshot Analysis has proven very effective. It will capture both true leaks and accretion of memory where the allocations are not accounted for by leaks. You can see all of the retain/release events, and their backtrace, using the Allocations instrument. Hit the little (i) button on the Allocations instrument … Read more

How do I verify reference count in ARC mode?

You can use CFGetRetainCount with Objective-C objects, even under ARC: NSLog(@”Retain count is %ld”, CFGetRetainCount((__bridge CFTypeRef)myObject)); This is not particularly useful for debugging, though, for reasons amply described elsewhere. If you need to understand where an object is being retained and released, check out this answer for help using the Allocations instrument. The only case … Read more

How can I fix this error: “ARC forbids explicit message send of ‘release’ in Xcode” [duplicate]

Solution #1: Just remove the release statement. ARC will manage it for you. [imageArray release]; // remove this line ARC is Auto Reference Counting. As opposite to manual reference counting. There are a few great videos of talks from WWDC. I can provide the link if you wish to watch them. In Transitioning to ARC … Read more

What is the difference in Swift between ‘unowned(safe)’ and ‘unowned(unsafe)’?

From what I understand, although I can’t find a definitive source from Apple, unowned can be broken into two flavors, safe and unsafe. A bare unowned is unowned(safe): it is a specially wrapped reference which will throw an exception when a dealloced instance is referenced. The special case is unowned(unsafe): it is the Swift equivalent … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)