Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>The Key-Value Coding Programming Guide seems to indicate that I need to save them as NSValues.</p> </blockquote> <p>No, you need an NSValue to pass a point or rectangle to <code>setValue:forKey:</code>. The KVC docs aren't talking about saving the values anywhere, since that isn't part of KVC. And you can't save an NSValue in a property list, since it isn't one of the <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/PropertyLists/" rel="nofollow noreferrer">property list</a> classes.</p> <p>So, you need to convert the rectangle to and from one of the property-list data types. I prefer to convert them to and from strings, which you can do with <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/doc/uid/TP40006894-CH3-SW34" rel="nofollow noreferrer">some of the functions in UIKit</a>.</p> <p>These are actually Core Graphics structures, not UIKit (hence the names <em>CG</em>Point and <em>CG</em>Rect), so you might expect Core Graphics to have functions for this. Indeed it does, but of a different sort: In <a href="http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CGGeometry/" rel="nofollow noreferrer">CGGeometry</a>, Core Graphics provides functions to convert CGPoints and CGRects to and from dictionaries.</p> <p>Strings or dictionaries: It's your choice. Whichever you choose, they are property lists, so you can store them in your property list output.</p> <p>On retrieval, convert the dictionary or string to a point or rectangle, and <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/NSValue_UIKit_Additions/" rel="nofollow noreferrer">create an NSValue with that</a> to pass to <code>setValue:forKey:</code>. Of course, this works in reverse the other way: When saving, <code>valueForKey:</code> will give you an NSValue, from which you need to extract the point or rectangle to convert to a dictionary or string to save in the plist.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload