Hi all,
I am getting errors when trying to add items to a NSMutableArray which is encapsulated within an object.
Code follows:
#import <Foundation/Foundation.h>
@interface TestObject : NSObject {
NSMutableArray *myArray;
}
@property (nonatomic, retain) NSMutableArray *myArray;
@end
#import "TestObject.h"
@implementation TestObject
@synthesize myArray;
- (id) init {
if(self= [super init]){
// Initialise the Mutable Array
myArray = [[NSMutableArray alloc] init];
}
return self;
}
- (void) dealloc {
[super dealloc];
[myArray release];
}
@end
Calling:
TestObject *testObject = [[TestObject alloc] init];
NSString *someString = @"blah blah blah";
NSLog(@"%@", someString);
[testObject.myArray addObject:someString];
NSLog(@"Test Object Array Count: %@", [testObject.myArray count]);
[testObject release];
Can anyone tell me why this throws an error when calling count?
I have also tried the copy the Mutable Array to a local variable and get the same result when calling count on the local variable.