When using a property of type NSMutableDictionary outside of the class I cannot add objects.
This is the class.h file
@interface cSummary : NSObject
{
@public
NSMutableDictionary* PaymentMethodSalesTotals;
}
@property (nonatomic, retain) NSMutableDictionary* PaymentMethodSalesTotals;
@end
The class.m file is like this
#import "cSummary.h"
@implementation cSummary
@synthesize PaymentMethodSalesTotals;
#pragma mark -
#pragma mark Initialisation
-(id)init
{
return [super init];
PaymentMethodSalesTotals = [[ NSMutableDictionary alloc] init];
[PaymentMethodSalesTotals setObject:[NSNumber numberWithFloat:0.0f] forKey:[NSNumber numberWithInt:10]];
[PaymentMethodSalesTotals setObject:[NSNumber numberWithFloat:0.0f] forKey:[NSNumber numberWithInt:20]];
[PaymentMethodSalesTotals setObject:[NSNumber numberWithFloat:0.0f] forKey:[NSNumber numberWithInt:30]];
}
#pragma mark -
#pragma mark Memory management
- (void)dealloc
{
if (PaymentMethodSalesTotals != nil)
[PaymentMethodSalesTotals release];
[super dealloc];
}
@end
Then this is used in another class like this
cSummary* oSummary = [[cSummary alloc] init];
NSNumber* numPrice = [NSNumber numberWithFloat:150.0f];
[oSummary.PaymentMethodSalesTotals setObject:numPrice forKey:[NSNumber numberWithInt:10]];
If I view this in debug the PaymentMethodSalesTotals collection still has no values in it?