iOS疯狂详解之SQlite数据库增删改查

Ionic Storage 深度解析:SQLite与IndexedDB跨平台持久化原理 在混合应用开发中,客户端数据持久化是离线能力的核心基础。SQLite作为嵌入式数据库代表,提供ACID事务与本地文件级可靠性;IndexedDB则是Web标准下的键值型存储方案,依赖浏览器实现。二者在Ionic框架中通过Storage抽象层统一接入,但实际行为受平台、WebView版本、权限模型深度影响。理解其驱动加载优先级、错误归一化机制、物理路径策略及WAL日志行为,是保障购物车、历史记录、人事档案等关键数据不丢失的前提。本文聚焦Ionic 2+中@ionic/storage的真实工作链路,结合adb调 阅读详情
//
//  SqLiteManager.h
//  MySqlite
//
//  Created by long on 15/9/15.
//  Copyright (c) 2015年 WLong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LanOuStudent.h"
#import <sqlite3.h>
@interface SqLiteManager : NSObject


+ (SqLiteManager *)shareManager;


//  打开数据库
- (sqlite3 *)openDB;

//  关闭数据库
- (void)closeDB;

//  创建表
- (void)createTable;

//  插入数据
- (void)insertWithStudent:(LanOuStudent *)student;

//  删除数据
- (void)deleteWithAge:(NSInteger)age;

//  更改数据  根据名字 更改学号
- (void)updateName:(NSString *)name byAge:(NSInteger)age;

//  查询学生  根据名字和学号
- (LanOuStudent *)queryStudentWithName:(NSString *)name age:(NSInteger)age;

//  查询全部学生
- (NSArray *)queryAllStudent;


@end

//
//  SqLiteManager.m
//  MySqlite
//
//  Created by long on 15/9/15.
//  Copyright (c) 2015年 WLong. All rights reserved.
//

#import "SqLiteManager.h"

@implementation SqLiteManager

+ (SqLiteManager *)shareManager
{
    static SqLiteManager *manager = nil;
    if (manager == nil) {
        manager = [[SqLiteManager alloc] init];
    }
    return manager;
}


//  定义一个静态区指针 连接数据库 让数据库再程序结束后自动释放
static sqlite3 *db = nil;

- (sqlite3 *)openDB
{
    //  说明已经打开数据库
    if (db != nil) {
        return db;
    }
    
    //  创建数据库
    //  先搞路径
    NSString *dbPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"Student.sqlite"];
    
    NSLog(@"%@",dbPath);
    
    //  如果没有Student.sqlite文件 会创建一个
    int result = sqlite3_open(dbPath.UTF8String, &db);
    
    if (result == SQLITE_OK) {
 
iOS开发中SQLite3基础操作实例:建表与CRUD SQLite3是轻量级的数据库,广泛应用于iOS应用中进行数据的持久化存储。作为关系型数据库,它不需要配置服务器即可在应用中运行,为开发者提供了一种高效便捷的本地数据存储解决方案。在iOS中使用SQLite3之前,无需安装额外的数据库服务器,因为它是作为应用的一部分被直接包含在应用包内。这就意味着,对于想要快速实现数据存储功能的开发者来说,SQLite3是一个非常适合的选择。本章将简要介绍SQLite3数据库的基本概念、优势以及在iOS中的应用场景,为后续章节深入探讨具体操作打下坚实的基础。 阅读详情

相关推荐

方差迭代计算公式

方差迭代计算过程推导术语约定递推公式过程推导 术语约定 (1)En=1n∑i=1nxi E_n =\frac{1}{n} \sum_{i=1}^{n}x_i \tag{1} En​=n1​i=1∑n​xi​(1) (2)F(n)=∑i=1n(x2−En) F(n) = \sum_{i=1}^{n}{(x^2-E_n)} \tag{2} F(n)=i=1∑n​(x2−En​)(2) (3)V(n)...

weixin_44479136的博客 7925

Transformer-Based Attention Networks for Continuous Pixel-Wise Prediction 基于Transformer注意力网络连续像素级与估计

Transformer-Based Attention Networks for Continuous Pixel-Wise Prediction 基于Transformer注意力网络的连续的像素级的

MengYa_Dream的博客 4723

【昇腾】用MindIE(服务化方式)拉起glm4-9b-chat模型问题解决

【昇腾】用MindIE拉起glm4-9b-chat模型问题解决: LLMInferEngine failed to init LLMInferModels ERR: Failed to init endpoint! Please check the service log or console output. Killed make sure the folder's owner has execute permission.

u014448841的博客 5123

ThinkBook 16p 2024 BIOS降压定频实战:从解锁CFG Lock到AC Loadline调优

高性能笔记本在满载时频繁撞上温度墙,通常源于固件层默认电压冗余过大,而系统级降压工具又受限于CFG Lock锁定。要根治问题,需要从BIOS固件层面理解电压管理机制——AC/DC Loadline参数控制着CPU在不同负载下的电压请求,通过修改这些负载线值可以安全降低电压,解锁CFG Lock后还能让XTU、ThrottleStop等软件调参工具恢复可用。这种BIOS级调优在工程实践中广泛用于改善散热、稳定频率、压降风扇噪音,尤其适用于联想ThinkBook 16p 2024与拯救者Y9000P等采用HX平

weixin_32496547的博客 399

win10删除vmware12后,重新安装失败(遗留注册表问题)解决总结

之前安装过一次VMware虚拟机,后来由于某些已遗忘原因把它卸载了,但是没有卸载完全,为以后安装留下了一些麻烦,现在根据我google很多内容总结后写下了自己的解决办法。 一些我搜的的可以用的VM12的注册码 5A02H-AU243-TZJ49-GTC7K-3C61N ZZ510-DYX47-48ERP-D6XZG-YCKU2 YV5MU-2FX5H-M841P-LZX5X-PYHX8

Jeason的博客 2万+

AI应用架构师收藏:大规模AI系统AIOps智能运维的4个落地案例

本文精选互联网、金融、制造、电信四大行业的大规模AI系统AIOps落地案例,覆盖云原生AI平台、风控AI系统、工业AI质检、5G网络AI优化等典型场景。行业背景与系统规模:业务目标、AI系统架构、运维挑战;AIOps解决方案设计:数据采集层→分析层→决策层的全栈架构,技术栈选型与理由;核心技术实现细节:异常检测算法、根因分析模型、自动化恢复流程(含Python代码示例);实施效果与经验总结:关键指标对比、踩坑教训、架构师视角的最佳实践。

AI天才研究院 869

022、Conv-BN-SiLU 基础卷积块:构造函数参数计算,前向传播的 PyTorch 逐行实现

本文详细解析了Conv-BN-SiLU卷积块的实现细节与注意事项。作者从调试经历出发,指出bias参数冗余会导致数值不稳定,强调卷积层应设置bias=False。文章对比了SiLU与ReLU的特性差异,逐行分析了构造函数参数计算(包括自动填充、分组卷积等)和前向传播过程,特别讲解了BN层与SiLU激活的数值特性。最后分享了三个实践中的常见问题:BN的momentum设置、SiLU输出范围的影响,以及分组卷积的通道对齐要求,并提供了卷积与BN融合的推理优化技巧。全文聚焦实际工程实现中的关键细节,具有较强实操指

ai技术增长的博客 224

Mamba SSM 实战:IMDb 文本分类 + Mamba-ssm 全流程

Mamba SSM 文本分类链路:IMDb 二分类 → MambaLMHeadModel (d_model=256, n_layer=8, d_state=16, exp2=2) → 末 token 分类头。5 epoch 达 89.2% 准确率 (与 BERT-base 持平), 但显存降低 44% (3.5GB vs 6.2GB)。建议序列长度 ≥ 1024 再选 Mamba, 短序列 (< 512) 用 BERT 更高效。扩展时注意d_state。

m0_71589036的博客 62

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: iOS疯狂详解之NSFileManager使用
下一篇: iOS疯狂详解之GCD
吊炸天-狂人
博客等级 码龄12年 87粉丝 42原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值