Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use an enumeration to define four options, e.g.:</p> <pre><code>typedef enum _NoteOptionType { kNoteOptionTypeOne, kNoteOptionTypeTwo, kNoteOptionTypeThree, kNoteOptionTypeFour, kNoteOptionTypes, } NoteOptionType; </code></pre> <p>These will be numbered 0 through 5. </p> <p>Core Data stores integers as <code>NSNumber</code> instances. You could perhaps keep an attribute in your <code>Note</code> entity that is called <code>optionType</code>, which stores the <code>NSNumber</code> equivalent of a <code>NoteOptionType</code> value.</p> <p>You can convert these to <code>NSNumber</code> options through something like, for example, <code>[NSNumber numberWithInt:kNoteOptionTypeOne]</code>.</p> <p>You could write a convenience method to convert a <code>NoteOptionType</code> to a string to put into a <code>UISegmentedControl</code>, e.g.:</p> <pre><code>+ (NSString *) keyForNoteOptionTypeTag:(NoteOptionType)optionTypeTag { if (optionTypeTag == kNoteOptionTypeOne) return [NSString stringWithFormat:@"First"]; else if (optionTypeTag == kNoteOptionTypeTwo) return [NSString stringWithFormat:@"Second"]; ... return [NSString stringWithFormat:@"Undefined"]; } </code></pre> <p>Reference it like so:</p> <pre><code>NSLog(@"second option is: %@", [Note keyForNoteOptionTypeTag:kNoteOptionTypeTwo]); </code></pre> <p>In your fetch, you can use the <code>NSNumber</code> values you put in your Core Data store as criteria on which to sort, through the use of an <code>NSSortDescriptor</code>, e.g.:</p> <pre><code>NSSortDescriptor *optionTypeDescriptor = [[NSSortDescriptor alloc] initWithKey:@"optionType" ascending:YES selector:nil]; NSArray *sortDescriptors = [NSArray arrayWithObjects:optionTypeDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; [optionTypeDescriptor release]; </code></pre>
    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. This table or related slice is empty.
    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