Note that there are some explanatory texts on larger screens.

plurals
  1. POretain/release issues
    text
    copied!<p>I just analyzed my iPhone project, and was very confused by the result XCode(4) gave me. For example, in one of my view controllers I have this code:</p> <pre><code>@property (nonatomic, retain) NSArray* menuItems; @property (nonatomic, retain) NSArray* menuItemsOptions; - (void)viewDidLoad { [super viewDidLoad]; self.menuItems = [[NSArray alloc] initWithObjects: NSLocalizedString(@"Foo", nil), NSLocalizedString(@"Bar", nil), nil]; [self.menuItems release]; self.menuItemsOptions = [[NSArray alloc] initWithObjects: NSLocalizedString(@"More foo", nil), NSLocalizedString(@"more bar", nil), nil]; [self.menuItemsOptions release]; ... } </code></pre> <p><code>menuItems</code> as well as <code>menuItemsOptions</code>are properties with the <code>retain</code>option. If I press analyze, XCode will show an error for the line <code>[self.menuItems release];</code>:</p> <p><a href="http://i54.tinypic.com/2rqkfaf.png" rel="nofollow">http://i54.tinypic.com/2rqkfaf.png</a></p> <p>To confuse me even more, XCode will <em>not</em> show errors for the line <code>[self.menuItemsOptions release];</code></p> <p>Similar situation in another method:</p> <p><a href="http://i55.tinypic.com/10hof9c.png" rel="nofollow">http://i55.tinypic.com/10hof9c.png</a></p> <p><code>theSelectedBegin</code> and <code>theSelectedEnd</code> are again properties with retain option.</p> <p>The reason why I'm posting this is that my app will actually crash with a very cryptic/not understandable backtrace within a third party library unless I add the <code>copy</code> seen on the last picture but <em>dont</em> add the <code>release</code>. Adding the <code>release</code>or omitting the <code>copy</code> will make the app crash again, this is why i decided to run the analyzer.</p> <p>What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload