【iOS】App仿写--管理系统

文章目录

  • 前言
  • 一、账号界面
  • 二、功能界面
  • 三、添加功能
  • 四、删除功能
  • 五、更改功能
  • 六、查找功能
  • 七、排序功能
  • 八、退出功能
  • 总结


前言

在日常生活中,如果用文字来记述与管理我们数据会十分麻烦,并且人工成本较高,这里笔者给出一种管理系统的模版,供大家借鉴,可凭借实际需求来创建所需要的管理系统

在先前C语言的学习过程中,笔者已经仿写过了学生管理系统,不过C语言的学生管理系统是没有UI的,所有功能都在控制台中实现,现用OC来仿写我们的管理系统


一、账号界面

这里的账号界面与3GShare大同小异,不再详细讲述,详见iOS–3GShare
唯一不同的就是在管理系统中使用了自定义字体,详见iOS自定义字体
在这里插入图片描述


二、功能界面

登录成功后首先出现的是我们功能界面,并且在功能界面显示了我们的人员信息
在这里插入图片描述
这里笔者使用了TableView来显示各项数据
在这里插入图片描述
在上面的第一行信息栏笔者使用了UILabel,这样可以根据自己的需要来更改管理系统需要管理的数据
在这里插入图片描述


三、添加功能

首先来看我们功能的实效效果
在这里插入图片描述
笔者的管理系统允许不同班级的有重名,但相同的鸡圈中不能有重名,同时成绩的区间需要在0-100之间,不能在这个区间之外,接下来放出具体实现代码:

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    NSString *s1 = _textField1.text;
    NSString *s2 = _textField2.text;
    NSString *s3 = _textField3.text;
    
    int boo1 = 0;
    int boo2 = 0;
    int boo3 = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]] && [s2 isEqualToString:_arrayClass[i]]) {
            boo1 = 1;
            boo2 = 1;
            break;
        }
        if (s3.integerValue < 0 || s3.integerValue > 100 || s2.integerValue < 0 || s2.integerValue > 10) {
            boo3 = 1;
            break;
        }
    }
    

    if (s1.length > 0 && s2.length > 0 && s3.length > 0){
        _textField1.text = @"";
        _textField2.text = @"";
        _textField3.text = @"";
        if (boo1 == 1 && boo2 == 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因已存在" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else if (boo3 == 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入信息不合法" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else {
            [_arrayName addObject:s1];
            [_arrayClass addObject:s2];
            [_arrayScore addObject:s3];
            [self.delegate addName:_arrayName addClass:_arrayClass addScore:_arrayScore];
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"添加成功" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self dismissViewControllerAnimated:YES completion:nil];
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        }
    } else {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    }
}

这里需要注意的是添加成功之后需要将新的数据回传给功能界面,然后接着进行下一步操作


四、删除功能

在这里插入图片描述
笔者的删除功能是需要给出要删除的名字与其对应的鸡圈,这是因为不同鸡圈中可能存在重名
具体实现代码:

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    NSString *s1 = _textField1.text;
    NSString *s2 = _textField2.text;
    
    int boo1 = 0;
    int boo2 = 0;
    
    int t = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]] && [s2 isEqualToString:_arrayClass[i]]) {
            boo1 = 1;
            boo2 = 1;
            t = i;
            break;
        }

    }
    

    if (s1.length > 0 && s2.length > 0 ){
        _textField1.text = @"";
        _textField2.text = @"";
        if (boo1 != 1 && boo2 != 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因不存在" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction1 = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self->_arrayName removeObjectAtIndex:t];
                [self->_arrayClass removeObjectAtIndex:t];
                [self->_arrayScore removeObjectAtIndex:t];
                [self.delegate deleteName:self->_arrayName deleteClass:self->_arrayClass deleteScore:self->_arrayScore];
                [self dismissViewControllerAnimated:YES completion:nil];
            }];
            UIAlertAction *confirmAction2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            }];
            [self.alert addAction:confirmAction2];
            [self.alert addAction:confirmAction1];
            [self presentViewController:self.alert animated:YES completion:nil];
        }
    } else {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    }
}

五、更改功能

在这里插入图片描述
笔者的更改功能是用来更改积分的,需要输入需要更改的名字与鸡圈,以此来避免重名导致更改错误的情况,然后输入我们需要更改的程序,然后将数据回传给我们的功能界面

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    NSString *s1 = _textField1.text;
    NSString *s2 = _textField2.text;
    NSString *s3 = _textField3.text;
    
    int f1 = 0;
    int f2 = 0;
    int f3 = 0;
    
    int boo1 = 0;
    int boo2 = 0;
    int boo3 = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]] && [s2 isEqualToString:_arrayClass[i]]) {
            boo1 = 1;
            boo2 = 1;
            f1 = i;
            f2 = i;
            break;
        }
        if ((s3.integerValue < 0 || s3.integerValue > 100 || s2.integerValue < 0 || s2.integerValue > 10) ) {
            boo3 = 1;
            break;
        }
    }
    

    if (s1.length > 0 && s2.length > 0 && s3.length > 0){
        _textField1.text = @"";
        _textField2.text = @"";
        _textField3.text = @"";
        if (boo1 == 0 && boo2 == 0) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因不存在" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else if (boo3 == 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入信息不合法" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认更改" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction1 = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self->_arrayName replaceObjectAtIndex:f1 withObject:s1];
                [self->_arrayClass replaceObjectAtIndex:f1 withObject:s2];
                [self->_arrayScore replaceObjectAtIndex:f1 withObject:s3];
                [self.delegate changeName:self->_arrayName changeClass:self->_arrayClass changeScore:self->_arrayScore];
                [self dismissViewControllerAnimated:YES completion:nil];
            }];
            UIAlertAction *confirmAction2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            }];
            [self.alert addAction:confirmAction2];
            [self.alert addAction:confirmAction1];
            [self presentViewController:self.alert animated:YES completion:nil];
        }
    } else {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    }
}

六、查找功能

在这里插入图片描述
因为存在不同鸡圈中有相同人名的情况,所以笔者这里仅仅根据名字来查找我们所需要的信息

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    _arrayFindName = [[NSMutableArray alloc] init];
    _arrayFindClass = [[NSMutableArray alloc] init];
    _arrayFindScore = [[NSMutableArray alloc] init];

    
    NSString *s1 = _textField1.text;

    int count = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]]) {
            [_arrayFindName addObject:_arrayName[i]];
            [_arrayFindClass addObject:_arrayClass[i]];
            [_arrayFindScore addObject:_arrayScore[i]];
            count++;
        }
    }
    if (count == 0) {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因不存在" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    } else {
        count = 0;
        [_tableView reloadData];
    }
    
}

七、排序功能

在这里插入图片描述
排序功能就比较简单了,这里既可以用我们c语言的排序方法来实现,也可以用OC创建排序描述符来实现

- (void)sort {
//    // 创建排序描述符,按照成绩降序排序
//    NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:NO comparator:^NSComparisonResult(id obj1, id obj2) {
//        // 这里假设成绩为字符串类型,如果成绩是数字类型,可以将其转换为 NSNumber 进行比较
//        return [obj1 compare:obj2 options:NSNumericSearch];
//    }];
//
//    // 对 _arrayScore 进行排序
//    NSArray *sortedArray = [_arrayScore sortedArrayUsingDescriptors:@[sortDescriptor]];
//
//    // 使用排序描述符对 _arrayName 和 _arrayClass 进行重排,保持对应关系
//    _arrayName = [[NSMutableArray alloc] initWithArray:[_arrayName sortedArrayUsingDescriptors:@[sortDescriptor]]];
//    _arrayClass = [[NSMutableArray alloc] initWithArray:[_arrayClass sortedArrayUsingDescriptors:@[sortDescriptor]]];
//    _arrayScore = [[NSMutableArray alloc] initWithArray:sortedArray];
//
//    // 刷新表格
//    [_tableView reloadData];
    
    for (int i = 0; i < _arrayName.count - 1; i++) {
        for (int j = i + 1; j < _arrayName.count; j++) {
            if ([_arrayScore[i] intValue] < [_arrayScore[j] intValue]) {//需要注意字符串比较,要转换为int类型比较
                id temp = _arrayName[i];
                _arrayName[i] = _arrayName[j];
                _arrayName[j] = temp;
                
                temp = _arrayClass[i];
                _arrayClass[i] = _arrayClass[j];
                _arrayClass[j] = temp;
                
                temp = _arrayScore[i];
                _arrayScore[i] = _arrayScore[j];
                _arrayScore[j] = temp;
            }
        }
    }
    [_tableView reloadData];
}

八、退出功能

在这里插入图片描述
退出功能只有两段代码

-(void)exit {
    // 获取主线程对象
    UIApplication *app = [UIApplication sharedApplication];
    
    // 发送退出信号,立即终止应用程序
    [app performSelector:@selector(terminateWithSuccess) withObject:nil afterDelay:0.0];
}

总结

这里只是管理系统的一种模版,大家可以通过实际需求来更改代码来统计数据

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/46502.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

[回馈]ASP.NET Core MVC开发实战之商城系统(二)

经过一段时间的准备&#xff0c;新的一期【ASP.NET Core MVC开发实战之商城系统】已经开始&#xff0c;在之前的文章中&#xff0c;讲解了商城系统的整体功能设计&#xff0c;页面布局设计&#xff0c;环境搭建&#xff0c;系统配置&#xff0c;及首页商品类型&#xff0c;bann…

【iOS】—— RunLoop和多线程相关问题总结

RunLoop 1. 讲讲RunLoop&#xff0c;项目中有用到过吗&#xff1f; RunLoop 的基本作用&#xff1a;保持程序的持续运行&#xff0c;节省 CPU 的资源&#xff0c;提高程序的性能 &#xff08; 没有事情&#xff0c;就请休眠&#xff0c;不要功耗。有事情&#xff0c;就处理&a…

二、SQL-6.DCL-1).用户管理

一、DCL介绍 Data Control Language 数据控制语言 用来管理数据库 用户、控制数据库的 访问权限。 二、语法 1、管理用户 管理用户在系统数据库mysql中的user表中创建、删除一个用户&#xff0c;需要Host&#xff08;主机名&#xff09;和User&#xff08;用户名&#xff0…

json-server创建静态服务器2

上次写的 nodejs创建静态服务器 这次再来个v2.0 利用json-server很方便就可以实现。 vscode打开文件夹&#xff0c;文件夹所在终端&#xff1a; json-server.cmd --watch db.json 这里视频教程是没有上述命令标红的&#xff0c;但是会报错&#xff0c;具体不详&#xff0c…

Docker私有仓库部署与管理

目录 Docker--harbor Harbor 简介 Harbor 部署 1. 部署 Docker-Compose 服务 2. 部署 Harbor 服务 维护管理Harbor 1. 通过 Harbor Web 创建项目 2. 创建 Harbor 用户 3. 查看日志 4. 修改 Harbor.cfg 配置文件 5. 移除 Harbor 服务容器同时保留镜像数据/数据库&…

Unity Profiler或UPR连接WebGL应用出错

问题 在使用Unity Build出WebGL应用进行性能测试的时候&#xff0c;勾选上了 Development Build和Autoconnect Profiler&#xff0c;分别使用Profiler和UPR进行测试 现象 使用Profiler测试时&#xff0c;就收到几帧&#xff0c;然后就没了 使用UPR进行测试时&#xff0c;在…

python简单入门

python简单入门 文章目录 python简单入门0. 地址链接1. 官网2.2. 下载地址3. 官方文档 1. 第一章1.1 python解释器1.2 基础语法1.2.1 常见数据类型1.2.2 强制类型转换1.2.3 注释1.2.4 运算符1.2.5 字符串1.2.5.1 字符串的定义1.2.5.2 字符串拼接1.2.5.3 格式化字符串1.2.5.3 精…

jenkins部署Springboot项目

文章目录 jenkins部署Springboot项目步骤创建一个jenkins任务开始配置准备步骤添加shell脚本(两个)你放一个执行也行构建成功后执行脚本 如何在linux上安装jenkins可以看上一篇 linux安装jenkins(详细步骤) jenkins部署Springboot项目步骤 创建一个jenkins任务 开始配置 ![在这…

error: /tmp/ccxy1wo0.o: multiple definition of ‘tgt_flow_thread_init‘

linux 项目使用Makefile 编译代码时&#xff0c;一直报错 从报错意思上看很明确&#xff0c;就是重复定义 tgt_flow_thread_init函数 但是我从全局搜索代码看根本不存在重复定义问题。 从网上看是说可能存在头文件有重复的定义或者头文件被重复的引用&#xff0c;但是我看了…

el-table树形表格实现复选框多选效果

2023.7.26今天我学习了如何使用树形表格的时候进行复选框的多选效果。 当我们使用树形结构表格需要进行多选功能操作的时候会发现点击全选的时候&#xff0c;只有一级表格数据会被选中&#xff0c;问题如图&#xff1a; 我们需要实现的是点击全选的不管是几级表格数据都可以被…

策略模式的实现与应用:掌握灵活算法切换的技巧

文章目录 常用的设计模式有以下几种&#xff1a;一.创建型模式&#xff08;Creational Patterns&#xff09;&#xff1a;二.结构型模式&#xff08;Structural Patterns&#xff09;&#xff1a;三.行为型模式&#xff08;Behavioral Patterns&#xff09;&#xff1a;四.并发…

k8s使用helm部署Harbor镜像仓库并启用SSL

1、部署nfs存储工具 参照&#xff1a;https://zhaoll.blog.csdn.net/article/details/128155767 2、部署helm 有多种安装方式&#xff0c;根据自己的k8s版本选择合适的helm版本 参考&#xff1a;https://blog.csdn.net/qq_30614345/article/details/131669319 3、部署Harbo…

matplotlib从起点出发(4)_Tutorial_4_Lifecycle

1 一幅图像的生命周期 本教程旨在揭示使用matplotlib绘制的一幅图像的生命周期&#xff0c;包括它的开始、中间和结束。我们将从一些原始数据开始&#xff0c;最后保存自定义可视化的图形。在此过程中&#xff0c;我们尝试使用matplotlib突出一些简洁的功能和最佳实践。 2 关…

三子棋(超详解+完整码源)

三子棋 前言一&#xff0c;游戏规则二&#xff0c;所需文件三&#xff0c;创建菜单四&#xff0c;游戏核心内容实现1.棋盘初始化1.棋盘展示3.玩家下棋4.电脑下棋5.游戏胜负判断6.game&#xff08;&#xff09;函数内部具体实现 四&#xff0c;游戏运行实操 前言 C语言实现三子棋…

maven

一、为什么需要使用maven 如今我们构建一个项目需要用到很多第三方的类库 &#xff0c;例如我们在开发项目中 需要引入 这些依赖jar包 一个项目Jar包的数量之多往往让我们瞠目结舌&#xff0c;并且Jar包之间的关系非常复杂&#xff0c;一个Jar包往往又会引用其他Jar包&#x…

安全学习DAY07_其他协议抓包技术

协议抓包技术-全局-APP&小程序&PC应用 抓包工具-Wireshark&科来分析&封包 TCPDump&#xff1a; 是可以将网络中传送的数据包完全截获下来提供分析。它支持针对网络层、协议、主机、网络或端口的过滤&#xff0c;并提供and、or、not等逻辑语句来帮助你去掉无用…

stable diffusion如何确保每张图的面部一致?

可以使用roop插件&#xff0c;确定好脸部图片后&#xff0c;使用roop固定&#xff0c;然后生成的所有图片都使用同一张脸。 这款插件的功能简单粗暴&#xff1a;一键换脸。 如图所示&#xff1a; 任意上传一张脸部清晰的图片&#xff0c;点击启用。 在其他提示词不变的情况下…

赛多利斯Sartorius天平java后端对接

业务场景 要将赛多利斯天平的数据读出来解析并且显示到对应的数字框,支持一台设备连接多种精度的天平 后端实现 通过协议解析数据,然后将数据存储 详细代码就不贴了,感兴趣的可以私聊我

GPT-AI 使用的技术概览

ChatGPT 使用的技术概览 智心AI-3.5/4模型&#xff0c;联网对话&#xff0c;MJ快速绘画 从去年 OpenAI 发布 ChatGPT 以来&#xff0c;AI 的能力再次惊艳了世人。在这样的一个时间节点&#xff0c;重新去学习相关技术显得很有必要。 ChatGPT 的内容很多&#xff0c;我计划采用…

3ds Max图文教程: 创建致命的冠状病毒动画

推荐&#xff1a; NSDT场景编辑器助你快速搭建可二次开发的3D应用场景 1. 病毒建模 步骤 1 打开 3ds Max。 打开 3ds Max 步骤 2 在透视视口中创建一个半径为 50&#xff0c;线段为 20 的 GeoSphere。 创建地球 步骤 3 打开修改器列表并将置换修改器应用于地理 球。 置换…
最新文章