alexyorke
alexyorke

Reputation: 4299

Should I use variables or arrays, or an nsdictionary in Objective c

I was wondering if I should use an nsdictionary to hold all of the values that my program uses. Or, I could stick with using many variables for each value.

If I use an NSDictionary/array I could release it all at once, rather than a bunch of variables. Unfortunately I am dealing with many memory leaks, so I thought that using an NSdictionary/array could help with the memory leaks.

Upvotes: 0

Views: 100

Answers (2)

Topher Fangio
Topher Fangio

Reputation: 20667

I guess it depends a bit on your application, but I would highly recommend that you look into Object Oriented Programming instead of using arrays, variables, etc.

I mean, technically, you'd still have those, but you would have an array of objects that would contain the variables you need, and it would know how to save itself if you implement the correct methods.

Upvotes: 2

Vadim Shender
Vadim Shender

Reputation: 6723

Misusing is always bad; only use NSDictionary/arrays when you need container. Better read docs and avoid memory leaks as the rest of us avoid them: write proper code.

Upvotes: 0

Related Questions