How to add an array to a dictionary.....
How to add an array to a dictionary.....
- Subject: How to add an array to a dictionary.....
- From: Keith Pritchard <email@hidden>
- Date: Sun, 13 Oct 2002 03:21:45 +0100
Hi,
I'm trying to dynamically create an NSMutable array of NSMutable
dictionaries with which to populate an outline view.
something like:-
Array
item contains
0 dictionary -> NSString name
-> NSArray children
0 dictionary ->NSString name
->NSArray children
1 dictionary....
and so on.... each created as the app goes on and accumulates more data.
Question is how to do this properly without memory leaking?
My problem at the moment is that I think I'm really making a massive
mess of memory management (I'm either creating one instance of the
children array rather than one per dictionary, or I'm creating lots but
managing to crash every time).
The code below, a result of frustration, manages to crash my app when I
try and populate it and since mail has crashed 4 times whilst writing
this email, I suspect I'm doing really horrible things to the system :)
helppp? Thanks!
NSMutableArray *thread;
thread=[[NSMutableArray alloc] initWithCapacity:0];
[thread addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
somonesName,@"name",
(NSMutableArray *)nextArticle=[[NSMutableArray
alloc]init],@"children",nil] ];
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.