Main Page | Report this Page
Computers Forum Index  »  Computer Languages (Objective-C)  »  Idiomatic OO Objective-C: NSNumber or primitive...
Page 1 of 1    

Idiomatic OO Objective-C: NSNumber or primitive...

Author Message
Grant Rettke...
Posted: Sun Jul 12, 2009 12:21 pm
Guest
When creating new classes, is it better taste to use NSNumber, or are
the primitive types often used?

Since said numbers will be encapsulated, refactoring is not an issue.
 
Stefan Arentz...
Posted: Sun Jul 12, 2009 6:24 pm
Guest
Grant Rettke <grettke at (no spam) gmail.com> writes:

Quote:
When creating new classes, is it better taste to use NSNumber, or are
the primitive types often used?

Since said numbers will be encapsulated, refactoring is not an issue.

It completely depends on your use case. I would say default to
primitive types. Switch to objects when you for example need to
support nil values. (0 != nil)

S.
 
Preston...
Posted: Wed Jul 22, 2009 8:18 pm
Guest
On 2009-07-12 06:21:15 -0600, Grant Rettke <grettke at (no spam) gmail.com> said:

Quote:
When creating new classes, is it better taste to use NSNumber, or are
the primitive types often used?

Since said numbers will be encapsulated, refactoring is not an issue.

Use the primitive types. NSValue and NSNumber are for when you need to
store primitive types in collections that only accept objects.
 
 
Page 1 of 1    
All times are GMT
The time now is Mon Dec 07, 2009 11:52 pm