MOST NEW TESTING:
I placed a NSLog(@"%p", self.myArray);
after the array assignment and I am seeing a address actually logged.....!?!?!
2012-03-06 01:33:52.618 ArrayTest[9883:f803] 0xae0f160
Seems that Xcode is all wacked out if it cant see the addess of that ivar in either local variables or with the tool tip highlight method...
Thoughts?
NEWEST TESTING: I created a brand new project.
It seems that simple assigning of objects to ivars is not working at all. If I look at the address of myArray after the assignment of the newly created array it has a null address.
output of nslog
2012-03-06 01:30:37.283 ArrayTest[9848:f803] (
)
(lldb)
//
// ViewController.h
// ArrayTest
//
// Created by Ben J Brown on 3/6/12.
// Copyright (c) 2012StudioBflat. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
NSMutableArray *myArray;
}
@property (strong) NSMutableArray *myArray;
@end
//
// ViewController.m
// ArrayTest
//
// Created by Ben J Brown on 3/6/12.
// Copyright (c) 2012 StudioBflat. All rights reserved.
//
#import "ViewController.h"
@implementation ViewController
@synthesize myArray;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSMutableArray *array = [NSMutableArray arrayWithCapacity:16];
self.myArray = array;
NSLog(@"%@",self.myArray); }
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
OLDER DATA:
In my viewDidLoad I have:
NSLog(@"%@",self.collectionOfImageViews);
self.collectionOfImageViews = [[NSMutableArray alloc] initWithCapacity:NUMBER_OF_COLUMNS*NUMBER_OF_ROWS];
NSLog(@"%@",self.collectionOfImageViews);
However later on when I access that array the array has an address but all the objects that I added to it are gone, and when I send a count message to that object(the NSMutableArray) it throws this in the console:
-[UIImage count]: unrecognized selector sent to instance 0x6b7ab40
My properties in my interface:
@property(strong) NSMutableArray* collectionOfImageViews;
and I have @synthesize collectionOfImageViews;
right after my @implmentation... what am I missing here?
Here is where I make the collection:
NSLog(@"%@",self.collectionOfImageViews);
self.collectionOfImageViews = [[NSMutableArray alloc] initWithCapacity:NUMBER_OF_COLUMNS*NUMBER_OF_ROWS];
NSLog(@"%@",self.collectionOfImageViews);
looking at the array it has a null address right after this action....
Concerning that earlier weird error where I had it consoling out that it was a UIImage not responding to count... I fixed that kinda by changing the order of the ivar declarations in the interface:
#import <UIKit/UIKit.h>
#import "TiledImageView.h"
@interface ViewController : UIViewController <TiledImageViewDelegation>
{
NSMutableArray *collectionOfImageViews;
UIImage *sourceImage;
UIImageView *currentTappedView;
}
@property(strong) NSMutableArray* collectionOfImageViews;
@property(strong) UIImage* sourceImage;
@property(strong) UIImageView* currentTappedView;
@end
As for where I fill the mutable array later here is that code:
iView = [[TiledImageView alloc] initWithImage:[UIImage imageWithCGImage:tempImage]];
iView.userInteractionEnabled = YES;
iView.delegate = self;
iView.contentMode = UIViewContentModeScaleAspectFit;
[iView setTag:index];
[iView setPosX:column];
[iView setPosY:row];
[collectionOfImageViews addObject:iView];
I'm pretty darnd confused because this is simple ivar setting and getting.. and alloc and initialization... something I have done many times before but it seems my ivars are not staying alive... I'm new to ARC.