Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

i.yalovecky

macrumors member
Original poster
Feb 24, 2010
67
0
With NSString all clear, if nil, so not set. But with CGPoint i not to get decision if only use CGPoint* and then use malloc and free, so if not set it will be nil to. In my program i have not untruth value for x and y.
And second way to use NSValue, but i don't sure about memory efficiency. As i know IPhone has strong memory limitation.
 
An uninitialised CGPoint will have x and y values set to zero.

If you want something you can check for nil then wrap your CGPoint in an object, as you suggest. The memory impact will be negligible (you can use the ObjAlloc tool to confirm this).
 
The obvious downside is that (0,0) is a perfectly valid point in many uses. If you want to have an "unset" value to then choose a value that can never be valid and initialise your unset points to that.

For most people a sensible value to choose would be CGFLOAT_MIN.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.