R
R
Roman Tarasov2012-08-12 00:52:41
Objective-C
Roman Tarasov, 2012-08-12 00:52:41

class or structure?

Help with advice to a beginner: what type of object is best to use to organize an NSMutableDictionary?
As I understand it, they usually use objects of some class, or you can wrap the structure in NSValue (withObjCType).
What is the difference?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
bobermaniac, 2012-08-12
@raym0n

If you have reference fields in the structure - like const char * - then withObjCType will not save you.
Use classes (NSObject descendants) wherever you don't have performance issues.

D
deleted-mifki, 2012-08-12
@deleted-mifki

withObjCType will not wrap the structure. Yes, and it makes sense to wrap it in NSValue, make a class right away.

R
Roman Tarasov, 2012-08-12
@raym0n

the structure is simple - a few floats. but the array is big enough and it's all for ios. In such a case would using a class be potentially slower than a struct?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question