Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface MyScrollView : UIScrollView { NSArray *_photosThumb; //the variables have _ prefix because then you can distinct them from properties NSArray *_photosFull; NSMutableArray *_photoItemsArray; } @property (nonatomic, retain) NSArray* photosThumb; @property (nonatomic, retain) NSArray* photosFull; @property (nonatomic, retain) NSMutableArray* photoItemsArray; @end #import "MyScrollView.h" @implementation MyScrollView @synthesize photosThumb = _photosThumb; //when you call photosThumb from outside, it returns _photosThumb @synthesize photosFull = _photosFull; @synthesize photoItemsArray = _photoItemsArray; -(id) initArraySmall:(NSArray*) _photos initArrayBig:(NSArray*) _photosBig{ _photosThumb = [[NSArray arrayWithArray: _photos] retain]; // retain &gt; take ownership of the object _photosFull = [[NSArray arrayWithArray: _photosBig] retain]; NSUInteger i, count = [_photosThumb count]; _photoItemsArray = [[NSMutableArray alloc] init]; for (i = 0; i &lt; count; i++) { UIButton* photoButton = [[UIButton alloc] init]; NSLog(@"MyButton 1: %d", [photoButton retainCount]); [photoButton addTarget:nil action:@selector(buttonDown: ) forControlEvents:UIControlEventTouchUpInside]; [_photoItemsArray addObject:photoButton]; NSLog(@"MyButton 2: %d", [photoButton retainCount]); [photoButton release]; NSLog(@"MyButton 3: %d", [photoButton retainCount]); [self addSubview:[_photoItemsArray lastObject]]; NSLog(@"MyButton 4: %d", [photoButton retainCount]); } NSLog(@"photosThumb: %d photosFull: %d", [_photosThumb retainCount], [_photosFull retainCount]); [_photoItemsArray removeAllObjects]; //this makes sure the array is empty [_photoItemsArray release]; // note: since this is a class variable you should put this in dealloc NSLog(@"photoItemsArray 1: %d", [_photoItemsArray retainCount]); return self; } - (void)dealloc { NSLog(@"dealloc"); [_photosThumb release]; //release what you "own" [_photosFull release]; /*[_photoItemsArray removeAllObjects]; [_photoItemsArray release];*/ [super dealloc]; } @end </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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