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

news2024/10/5 19:20:03

文章目录

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


前言

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

在先前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.coloradmin.cn/o/783467.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

DSP开发软件css(10)使用基础(汉化、工程导入、设置目标配置文件、选择仿真器和芯片型号、添加文件|库路径、编译下载等操作)

DSP开发软件css(10)使用基础(汉化、工程导入、设置目标配置文件、选择仿真器和芯片型号、添加文件|库路径、编译下载等操作&#xff09; 文章目录 DSP开发软件css(10)使用基础(汉化、工程导入、设置目标配置文件、选择仿真器和芯片型号、添加文件|库路径、编译下载等操作&#…

中医-十二经-图

&#x1f33c;十二经-图 &#x1f354;十二经&#x1f36d;任脉、督脉&#x1f957;冲脉、带脉&#x1f96a;阴维、阳维&#x1f368;资源下载 &#x1f354;十二经 &#x1f36d;任脉、督脉 &#x1f957;冲脉、带脉 &#x1f96a;阴维、阳维 &#x1f368;资源下载 如果需要…

SESSION,TOKEN和Postman的使用

SESSION&#xff1a;它是存储在服务端的 1、客户端输入账户和密码&#xff0c;登录成功&#xff0c;在服务端生成一个SESSIONID同时存储在服务端&#xff08;DB or Redis&#xff09; 2、服务端把生成的SESSIONID通过响应头中的Set-Cookie返回给客户端 3、再系统下个请求中&…

机器视觉运动控制快组态软件RTFuse在XYZ三轴运动平台的应用方案

一、RTFuse市场应用背景 面对工业自动化领域对视觉运动控制低代码、低门槛的市场应用需求日益增加&#xff0c;正运动特此推荐一款RTFuse快组态软件&#xff0c;以满足这一需求&#xff0c;使机器视觉运动控制项目开发变得更加简单易用。 RTFuse快组态软件&#xff0c;内置的…

GnuWin32,Windows下使用Linux命令

1. 前言 昨天我写了一篇 UnxUtils工具包&#xff0c;Windows下使用Linux命令 的文章&#xff0c;今天无意间又发现了 GnuWin32 &#xff0c;它提供Win32版本的GNU工具&#xff08;Linux下的命令基本都有&#xff09;。 你可以在 GnuWin32 Files 手动下载你想要的命令安装包。 …

centos7 访问windows系统的共享文件夹

window系统上共享文件夹 选择共享文件夹&#xff0c;点击属性 点击共享 选择用户&#xff0c;点击共享 centos系统挂载共享文件夹 创建挂载目的文件夹 mkdir -p /mnt/smb 挂载命令 mount -t cifs -o usernamezenglg,password*** //192.168.1.10/ftp /mnt/smb/其中&#xff…

新星计划打卡学习:VUE3组合式API

目录 1、vue3组件页面的构成 2、setup选项 3、reactive 4、ref 最后 1、vue3组件页面的构成 从上到下依次是 逻辑、结构、样式 2、setup选项 经过语法糖的封装更简单的使用组合式api <script setup> // 经过语法糖的封装更简单的使用组合式api const message t…

SpringCloudAlibaba微服务实战系列(三)Sentinel1.8.0+流控

SpringCloudAlibaba–Sentinel Sentinel被称为分布式系统的流量防卫兵&#xff0c;是阿里开源流量框架&#xff0c;从服务限流、降级、熔断等多个纬度保护服务。Sentinel同时提供了简洁易用的控制台&#xff0c;可以看到接入应用的秒级数据&#xff0c;并可以在控制台设置一些…

Cookie 和 Session 区别——2023最新面试精简版本

Cookie 和 Session 的区别 原理&#xff1a;从”登录“过程看Jwt和Token&#xff0c;以及区分Cookie和Session概念 面试&#xff1a; 好的&#xff0c;面试官。 我先解释一下 Cookie&#xff0c;它是客户端浏览器用来保存服务端数据的一种机制。 当通过浏览器进行网页访问的时…

Redis原理篇(一)

一、原理篇-Redis数据结构 1.1 Redis数据结构-动态字符串 我们都知道Redis中保存的Key是字符串&#xff0c;value往往是字符串或者字符串的集合。可见字符串是Redis中最常用的一种数据结构。 Redis虽由C语言开发&#xff0c;不过Redis没有直接使用C语言中的字符串&#xff0…

vulnhub靶机Thales:1

Thales:1 靶机地址&#xff1a;Thales: 1 ~ VulnHub 主机发现 arp-scan -l 扫描端口 nmap --min-rate 10000 -p- 192.168.21.135 nmap -sV -sT -O -p22,8080 192.168.21.135 简单的漏洞的扫描 nmap --scriptvuln -p22,8080 192.168.21.135 答题思路就是从8080端口拿到账号密…

MS VC 2022开发Linux应用记录之01篇

安装MSVS2022的时候勾上对开发Linux C程序的选项在Windows中安装Oracle Virtual Box程序&#xff0c;在里面安装Ubuntu最新稳定版,要选择多个CPU核在VirtualBox中添加一个网卡,选择Host Only在虚拟机中使用ifconfig命令&#xff0c;在宿主机中使用ipconfig, 可以看到两者存在同…

有限状态自动机

1 什么是有限状态自动机 1.1什么是计算 维基百科定义&#xff1a;计算&#xff08;英语&#xff1a;Calculation&#xff09;是一种将“单一或多个的输入值”转换为“单一或多个的结果”的一种思考过程。可以简单理解为给出一个问题得到一个答案的过程。如下图所示日常生活比…

AITO问界,先经沧海而后造船

IT领域最重要的原则之一&#xff0c;就是软件快速迭代。 对于科技产品来说&#xff0c;需求永远在升级。一项技术或软件系统问世之后&#xff0c;如果后续不再迭代&#xff0c;结果可能是灾难性的。 比如几年前&#xff0c;很多读者可能都买过一些“不了了之”的智能消费硬件&a…

性能测试Ⅳ

在进行性能测试的时候需要使用不同阶段的数据来测试&#xff0c;分析不同数据下资源的情况。 java -jar -Xms1M -Xmx1M -XX:MaxMetaspaceSize10m DBPlus-0.0.1-SNAPSHOT.jar 最小内存 最大内存 如果内存太小会导致内存泄露 启动程序 java -Djava.rmi.serv…

JavaWeb课程设计项目实战(09)——项目编码实践6

版权声明 本文原创作者&#xff1a;谷哥的小弟作者博客地址&#xff1a;http://blog.csdn.net/lfdfhl 在本节教程中&#xff0c;我们实现修改学生的功能。当在学生列表页面点击修改后首先将依据id查询该生的详细信息&#xff0c;然后将这些信息展示在修改页面。当完成学生信息…

Transformer Encoder (Bert)

参考&#xff1a;图解Self-Attention_子燕若水的博客-CSDN博客 举个例子&#xff1a; 假设输入数据形状为(243,34),表示的是243帧,每帧包含34个特征(比如17个关键点的x,y坐标)。那么这个数据在Transformer Encoder中的流动过程如下: 输入数据shape是(243, 34),表示243个时间…

【字符流】案例:点名器

案例&#xff1a;点名器 1.需求&#xff1a; 我有一个文件里面存储了班级同学的姓名&#xff0c;每一个姓名占一行&#xff0c;要求通过程序实现随机点名器 2.思路&#xff1a; 创建字符缓冲输入流对象创建ArrayList集合对象调用字符缓冲输入流对象的方法读数据把读取到的字…

vue ---- filters过滤器中不能使用this问题

在日常开发中&#xff0c;使用filters是很正常&#xff0c;最近遇到切换单位&#xff0c;页面上显示的数据要根据单位转换&#xff0c;这时就需要根据data里面的变量去转换&#xff0c;可是filters里面不能使用this 解决&#xff1a; 1、先在return中声明一个变量that&#xf…

vuejs源码之模版编译原理

之前我们说过虚拟dom&#xff0c;也就是虚拟dom拿到vnode后所做的事情&#xff0c;而模版编译是如何让虚拟dom拿到vnode。 模版编译的目标就是生成渲染函数&#xff0c;而渲染函数的作用是每次执行它&#xff0c;它就会使用当前最新的状态生成一份新的vnode&#xff0c;然后用…