美文网首页
FMDB Model

FMDB Model

作者: 黑市掌柜 | 来源:发表于2017-06-30 13:43 被阅读11次

配置cocoaPods配置第三方文件

第一步。打开终端

第二步。cd+文件夹

第三步。pod init

第四步。打开podfild文件

第五步。pod install 安装第三方

展示界面oneviewcontroll:

#import "OneViewController.h"

#import "FMDateFiction.h"

#import "FMDateFictionModel.h"

#import "tianjiaViewController.h"

#import "xiugaiViewController.h"

{

UITableView *theTable;

NSArray *theArr;

}

-(void)viewWillAppear:(BOOL)animated

{

theArr = [[FMDateFiction sharedFM]getAll];

[theTable reloadData];

}

- (void)viewDidLoad {

[super viewDidLoad];

self.view.backgroundColor = [UIColor whiteColor];

theTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)style:UITableViewStyleGrouped];

theTable.delegate = self;

theTable.dataSource =self;

theTable.rowHeight = 80;

[self.view addSubview:theTable];

self.navigationItem.title = @"物流信息";

UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"添加" style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOKbtn)];

self.navigationItem.rightBarButtonItem = rightBarItem;

}

-(void)onClickedOKbtn

{

NSLog(@"添加");

tianjiaViewController *theT = [[tianjiaViewController alloc]init];

[self.navigationController pushViewController:theT animated:NO];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return theArr.count;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *Str = @"Cell";

UITableViewCell *theTVC = [tableView dequeueReusableCellWithIdentifier:Str];

if (!theTVC) {

theTVC = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"];

}

FMDateFictionModel *theModel = theArr[indexPath.row];

NSString *ss = [NSString stringWithFormat:@"类型:%@  收人:%@  手机号:%@",theModel.theFenglei,theModel.theShouHuoRen,theModel.theDianHua];

theTVC.textLabel.text =ss;

NSString *theSS = [NSString stringWithFormat:@"收获地址:%@    备注:%@",theModel.theDiZhi,theModel.theBeiZhu];

theTVC.detailTextLabel.text = theSS;

return theTVC;

}

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{

FMDateFictionModel *m = [theArr objectAtIndex:indexPath.row];

[[FMDateFiction sharedFM]deleteMusic:m];

theArr = [[FMDateFiction sharedFM]getAll];

[theTable reloadData];

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

xiugaiViewController *theXG = [[xiugaiViewController alloc]init];

[self.navigationController pushViewController:theXG animated:NO];

}

在ViewControll里:

tianjiaViewController:

self.view.backgroundColor = [UIColor whiteColor];

theYoujian = [[UITextField alloc]initWithFrame:CGRectMake(50, 100, self.view.frame.size.width-100, 40)];

theYoujian.backgroundColor = [UIColor greenColor];

theYoujian.placeholder = @"型";

[self.view addSubview:theYoujian];

thedizhi = [[UITextField alloc]initWithFrame:CGRectMake(50, 150, self.view.frame.size.width-100, 40)];

thedizhi.backgroundColor = [UIColor greenColor];

thedizhi.placeholder = @"收";

[self.view addSubview:thedizhi];

theshouren = [[UITextField alloc]initWithFrame:CGRectMake(50, 200, self.view.frame.size.width-100, 40)];

theshouren.backgroundColor = [UIColor greenColor];

theshouren.placeholder = @"人";

[self.view addSubview:theshouren];

thedianhua = [[UITextField alloc]initWithFrame:CGRectMake(50, 250, self.view.frame.size.width-100, 40)];

thedianhua.backgroundColor = [UIColor greenColor];

thedianhua.placeholder = @"话";

[self.view addSubview:thedianhua];

thebeizhu = [[UITextField alloc]initWithFrame:CGRectMake(50, 300, self.view.frame.size.width-100, 40)];

thebeizhu.backgroundColor = [UIColor greenColor];

thebeizhu.placeholder = @"注";

[self.view addSubview:thebeizhu];

UIButton *theyanzheng = [[UIButton alloc]initWithFrame:CGRectMake(100, 350, self.view.frame.size.width-200, 40)];

theyanzheng.backgroundColor = [UIColor redColor];

[theyanzheng setTitle:@"添加" forState:UIControlStateNormal];

[theyanzheng addTarget:self action:@selector(tianjia) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:theyanzheng];

}

-(void)tianjia

{

FMDateFictionModel *theModel = [[FMDateFictionModel alloc]init];

theModel.theFenglei = theYoujian.text;

theModel.theShouHuoRen = theshouren.text;

theModel.theDiZhi = thedizhi.text;

theModel.theDianHua = thedianhua.text;

theModel.theBeiZhu = thebeizhu.text;

[[FMDateFiction sharedFM]insertMusic:theModel];

[self.navigationController popViewControllerAnimated:NO];

}

xiugaiViewController里:

FMDateFictionModel.h里:

FMDateFictionModel.m里

FMDateFictionmodel.h里:

相关文章

  • FMDB Model

    配置cocoaPods配置第三方文件 第一步。打开终端 第二步。cd+文件夹 第三步。pod init 第四步。打...

  • FMDB增删改查(成绩查询)

    首先 导入FMDB 并添加FMDB依赖库(labslite3.0) 创建model类 如图 紧接着创建业务处理层...

  • FMDB(ZHY)

    //ViewController代码(model数据以及FMDB包没有上传) #import "ViewContr...

  • iOS 常用三方库

    AFNetworking 网络请求组件 MJExtension 用于json转model进行使用 FMDB 本地数...

  • JQFMDB

    pod 'JQFMDB' FMDB的封装,操作简单,线程安全,扩展性强,直接操作model或dictionary

  • FMDB框架的使用

    FMDB是操作数据库的一个框架,其中包含了很多的有用的方法。看看FMDB框架是怎么用的。 1.数据model 2....

  • 基于FMDB封装-直接存Model,取Model

    项目中经常遇到数据持久化的问题,直接使用FMDB比较麻烦,我想直接存Model数据源,然后直接建表,存储。 思路是...

  • JQFMDB,操作简单,线程安全,扩展性强

    JQFMDB的特性 针对于FMDB的二次封装 线程安全 操作简单, Model和Dictionary直接存储 拓展...

  • 使用 YTKKeyValueStore 做 iOS离线缓存(FM

    另一种 JQFMDB FMDB的封装,操作简单,线程安全,扩展性强,直接操作model或dictionary YT...

  • LKDBHelper和MagicalRecord的基本用法

    LKDBHelper是对FMDB的封装,可以在不写sql语句的情况下,使用model就可以全自动的进行数据表的创建...

网友评论

      本文标题:FMDB Model

      本文链接:https://www.haomeiwen.com/subject/znbbcxtx.html