Note that there are some explanatory texts on larger screens.

plurals
  1. POInstance method unable to read class instance variables
    primarykey
    data
    text
    <p>Problem: Variables from a class are being overlooked somehow when the method is called from a different class.</p> <p>Basically: I have Class A, Class B. I also have Method A, Method B each in their respective classes.</p> <p>When calling Method A from Class B Method B, I can NSLog values fine, however I cannot access an NSMutableArray contained within Class A. There is my issue.</p> <pre><code>// Class B - (id)init { self = [super init]; if (self) { // Initialization code here. foodListingObj = [[FoodListing alloc] initWithNibName:@"FoodListing" bundle:nil]; } return self; } - (void)toggleImage //Method B in Class B { [foodListingObj didToggle:self.indexOfToggledCell]; } // Method in Class A - (void)didToggle:(NSIndexPath *)toggledIndexPath{ //[_toggledIndexArray addObject:toggledIndexPath]; [_toggledIndexArray addObject:@"Anything"]; } // Method in Class A - (void)checkArray{ // Log the count of the array // it always says 1 because I intialize the array // then add an an object like so [_toggledIndexArray addObject@"hi"]; // in my ViewDidLoad Method. Hence it appears that the array is still around // (not deallocated), but yet my method cannot seem to touch it... NSLog(@"%i",[_toggledIndexArray count]); } // dealloc for Class A - (void)dealloc{ // I release the array among other things [_toggledIndexArray release]; } </code></pre> <p>The array (_toggledIndexArray) is a property declared in the header, and is initialized in Class A's viewDidLoad with</p> <pre><code>_toggledIndexArray = [[NSMutableArray alloc] init]; </code></pre> <p>The error is the fact that Method A does not seem to affect the array for a reason unknown to me.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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