Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a couple of observations which may or may not be relevant.</p> <ul> <li>The code you posted is absolutely OK from Obj-C's point of view.</li> <li>Instead of <code>[super init]</code> you should really call UIViewController's designated initializer, <code>initWithNibName:bundle:</code>.</li> <li>You named the method <code>initWithBaseURL:</code>, but it takes NSString as an argument. While that does match the declaration in @interface, make sure you don't expect baseURL to be an NSURL object somewhere else in your code.</li> <li>What happens when you remove <code>@private</code>? I suspect nothing changes with regard to the exception you see.</li> </ul> <p>Make sure you don't do this:</p> <pre><code>NSString *myURL = [NSString stringWithFormat:...]; // myURL is autoreleased SignInViewController *controller = [[SignInViewController alloc] initWithBaseURL: myURL]; // retains myURL because it's immutable [myURL release]; // does not crash because myURL has been *retained* // baseURL is left with 0 retain count </code></pre> <p>You can verify that sending <code>copy</code> to an NSMutableString does produce another object, while sending <code>copy</code> to an immutable NSString is equivalent to <code>retain</code>, just because wasting memory on exact copies of immutable objects is inefficient. If baseURL were indeed a <em>copy</em> of myURL, the crash would happen when the autorelease pool was drained.</p> <p>In other words, a mistake may be in one place, only to manifest itself in another. The above example is not too contrived.</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