Slinky
Slinky

Reputation: 5832

Copy contents from a master nsdictionary to another nsdictionary

Need to know the best way to copy the contents of an NSMutableDictionary into another NSMutableDictionary.

I have about 10 categories, that each have their own lists:

enter image description here

I have a UITableView that uses a class member called listContent as its datasource:

@property (nonatomic) NSMutableDictionary *listContent;

I then need to save the contents of listContent into another list:

//Cached list results
@property (nonatomic) NSMutableDictionary *listContentCategory1;
@property (nonatomic) NSMutableDictionary *listContentCategory2;
@property (nonatomic) NSMutableDictionary *listContentCategory3;

This is to save the overhead of fetching results that were fetched previously.

Simply doing self.listContentCategory1 = self.listContent; is not copying the current contents of self.listContent into self.listContentCategory1.

Should I be using (nonatomic,copy), in self.listContentCategory1,self.listContentCategory2?

(1) How should I set up my properties for self.listContent and self.listContentCategoy1,self.listContentCategoy2,etc?

(2) Best way do the assignment?

Thanks!

Upvotes: 0

Views: 1312

Answers (1)

Mario
Mario

Reputation: 4520

self.listContentCategory1 = [NSMutableDictionary dictionaryWithDictionary: Self.listContent];

Make the properties (nonatomic, retain)

Upvotes: 1

Related Questions