未验证 提交 c2ea11d3 编写于 作者: Y yixiangboy 提交者: GitHub

Merge pull request #348 from 0xd-cc/feature/userdefaults_sort

feat: NSUserDefaults 按照key值排序 & 增加在列表删除单个key的功能
......@@ -44,6 +44,9 @@
model.value = obj;
[self.modelList addObject:model];
}];
[self.modelList sortUsingComparator:^NSComparisonResult(DoraemonNSUserDefaultsModel * _Nonnull obj1, DoraemonNSUserDefaultsModel * _Nonnull obj2) {
return [obj1.key.lowercaseString compare:obj2.key.lowercaseString];
}];
[self.tableView reloadData];
}
......@@ -64,6 +67,18 @@
return cell;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleDelete;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
if (editingStyle == UITableViewCellEditingStyleDelete) {
DoraemonNSUserDefaultsModel *model = _modelList[indexPath.row];
[[NSUserDefaults standardUserDefaults] setValue:nil forKey:model.key];
[self reload];
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DoraemonNSUserDefaultsModel *model = self.modelList[indexPath.row];
DoraemonNSUserDefaultsEditViewController *vc = [[DoraemonNSUserDefaultsEditViewController alloc] initWithModel:model];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册