
User Defaults Definition - Store index of selected detail item
#1
Posted 14 April 2013 - 09:47 PM
Is there a way to store the index of the item selected, rather than the value of the cell text?
Thank you!
#2
Posted 14 April 2013 - 10:09 PM
if ( cell type is an SCSelection Cell ) { NSUInteger selectedIndex = [detailModel.activeCellIndexPath row]; [[NSUserDefaults standardUserDefaults] setInteger:selectedIndex forKey:cell.boundPropertyName]; }
#3
Posted 16 April 2013 - 08:15 PM
#4
Posted 12 August 2015 - 04:31 PM
Hi,
I'm new to STV and i need help, so instead of creating a new topic, i make a reply here.
I have the same situation and my settings part are IB only. I think there are nothing to do without making code, right ?
Thanks.
#5
Posted 12 August 2015 - 06:42 PM
Hi skrew,
Yes, it's basically done through code. Sam showed one example above, and I'll give you another one. To have our bundled UserDefaultsApp sample store ringtone as an index, you'd add the following code to MasterViewController.m:
@implementation MasterViewController - (void)viewDidLoad { [super viewDidLoad]; SCObjectSection *alarmSection = (SCObjectSection *)[self.tableViewModel sectionAtIndex:1]; SCSelectionCell *ringtoneSelectionCell = (SCSelectionCell *)[alarmSection cellForPropertyName:@"ringtone"]; ringtoneSelectionCell.boundPropertyDataType = SCDataTypeInt; } @end
Please let me know if you need any further help with this.
#7
Posted 13 August 2015 - 08:33 AM
Hi skrew,
Yes, I just tested it and it's not working, which seems to be an STV bug. I really apologize for not testing the code before posting. Please use the following code instead:
@implementation MasterViewController - (void)viewDidLoad { [super viewDidLoad]; SCObjectSection *alarmSection = (SCObjectSection *)[self.tableViewModel sectionAtIndex:1]; SCSelectionCell *ringtoneSelectionCell = (SCSelectionCell *)[alarmSection cellForPropertyName:@"ringtone"]; ringtoneSelectionCell.cellActions.willCommitBoundValue = ^NSObject*(SCTableViewCell *cell, NSIndexPath *indexPath, NSObject *value) { return [(SCSelectionCell *)cell selectedItemIndex]; }; } @end
Also, based on your input, we're now working on having this feature accessible right from IB without you having to do any coding. Please let me know if you need any further help.
Edited by Tarek, 13 August 2015 - 08:35 AM.
Fix
#8
Posted 13 August 2015 - 09:16 AM
Ok thanks Tarek, it's works now.
And having this feature in IB are a good news too
- Tarek likes this
#9
Posted 21 January 2016 - 10:23 AM
Hi,
Any news about storing indexes without using code ?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users