release not raising error

I'm trying to move an existing non-ARC project to ARC. I have set the Objective-C Automatic Reference Counting flag in Build Settings to YES.

This has of course created a lot of errors about sending explicit release/autorelease messages. For errors that were in my code, I removed the explicit release messages, dealloc blocks etc. For errors generated in third party libraries (like ASIHTTPRequest) I added the -fno-objc-arc flag for the required files in Build Phases - Compile Sources section.

However after I fixed all errors (and the project compiles successfully), I still have release statements in my code.

For example in the app delegate I use the following:

self.loginViewController       = [[LoginViewController alloc] init];
self.window.rootViewController = self.loginViewController;
[self.window makeKeyAndVisible];
[self.loginViewController release];

Now as I understand, this should have raised an error. But it doesn't. The app works as intended, but leaves me with questions on whether memory management is properly done in these files.

Neither the AppDelegate.m nor LoginViewController.m have the -fno-objc-arc flag set, so they should be defaulting to ARC.

Definitely I am doing something wrong. What should I double-check?

Thanks in advance.


I just solved this issue. I was using iRate library and in one of its headers it defines release and autorelease

#define release self
#define autorelease self

I deleted those lines and the problem was fixed. So if you ever encounter something like this, check if some 3rd party library has defined them.

Seriously, which decent programmer would define "release" and "autorelease" like this? Amazing...

链接地址: http://www.djcxy.com/p/72762.html

上一篇: 限制在ios中使用autorelease池

下一篇: 释放不会引起错误