Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy would this code crash with EXC_BAD_ACCESS during NSArray InitWithObjects
    text
    copied!<p>Notice in the code below, the two NSLOG statements. The "aaa" gets printed out but the "bbb" never does. Instead, the simulator crashes with EXC_BAD_ACCESS. I know that this typically means that the object I am trying to access has been prematurely released. I just can't figure out what is wrong...</p> <p>Updated:</p> <p>here is my .h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface vcAddCat : UIViewController &lt;UIPickerViewDataSource, UIPickerViewDelegate&gt; { NSManagedObjectContext *managedObjectContext; IBOutlet UIPickerView * pickerView; NSArray * _weights; NSArray * _categories; IBOutlet UILabel *lastCat; IBOutlet UILabel *lastWeight; </code></pre> <p>}</p> <p>I do not have any @property or @synthesize lines for either array...</p> <p>Here are two snips from my .m</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"&gt;&gt;&gt; Entering %s &lt;&lt;&lt;", __PRETTY_FUNCTION__); _categories=[[NSArray alloc] initWithObjects: @"Homework",@"Quizzes",@"Tests", @"Mid-Term Exam", nil]; ; NSLog(@"aaa"); _weights=[[NSArray alloc] initWithObjects: @"1",@"2",@"3",@"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", @"19", @"20", @"21",@"22",@"23", @"24", @"25", nil]; NSLog(@"bbb"); </code></pre> <p>..and here is where I release the arrays...</p> <pre><code>- (void)dealloc { [super dealloc]; [_categories release]; [_weights release]; NSLog(@"&gt;&gt;&gt; Leaving %s &lt;&lt;&lt;", __PRETTY_FUNCTION__); </code></pre> <p>}</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