This is what I have though every time I run the method it initialises the Dictionary though I want to add more information to it for the duration of the program.
This is for an application for iPhone.
In the header file I've got:
In the .m file I have this as I'm trying to initialize it here as I read to take this out of the function to stop it from resetting the Dictionary. Though I cant get this to work.
in the method where I'm adding to the Dictionary I can only get things adding to it when I put:
Where should I put the line:
as it is doing nothing in viewDidLoad and resets the dictionary in the method where I'm setting objects.
This is for an application for iPhone.
In the header file I've got:
Code:
@interface ViewController : UIViewController
{
NSMutableDictionary *dictionary;
}
-(void)viewDidLoad;
@property (nonatomic, retain) NSDictionary *dictionary;
In the .m file I have this as I'm trying to initialize it here as I read to take this out of the function to stop it from resetting the Dictionary. Though I cant get this to work.
Code:
-(void)viewDidLoad
{
self.dictionary = [[NSMutableDictionary alloc] init ];
}
in the method where I'm adding to the Dictionary I can only get things adding to it when I put:
Code:
dictionary = [[NSMutableDictionary alloc] init ];
Where should I put the line:
Code:
dictionary = [[NSMutableDictionary alloc] init ];
as it is doing nothing in viewDidLoad and resets the dictionary in the method where I'm setting objects.
Code:
//this is after the viewDidLoad Method
-(void)addToNSDict: (NSString*)value
{
//I think this is the one that is resetting the dictionary
//so I'm unsure where to put it
dictionary = [[NSMutableDictionary alloc] init ];
[ dictionary setObject:value forKey:@"Current Number"];
// prints the current dictionary
CFShow (CFBridgingRetain(dictionary));
}
Last edited: