UI2_NSUserDefaults
//
// ViewController.m
// UI2_NSUserDefaults
//
// Created by zhangxueming on 15/7/8.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *textString = [defaults objectForKey:@"key"];
if (textString) {
NSLog(@"textString = %@",textString);
}
else
{
NSLog(@"程序第一次启动");
} UIButton *writeBtn = [UIButton buttonWithType:UIButtonTypeSystem];
writeBtn.frame = CGRectMake(100, 100, self.view.frame.size.width-200, 50);
[writeBtn setTitle:@"写入数据" forState:UIControlStateNormal];
[writeBtn addTarget:self action:@selector(writeBtnClicked) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:writeBtn]; UIButton *deleteBtn = [UIButton buttonWithType:UIButtonTypeSystem];
deleteBtn.frame = CGRectMake(100, 200, self.view.frame.size.width-200, 50);
[deleteBtn setTitle:@"删除数据" forState:UIControlStateNormal];
[deleteBtn addTarget:self action:@selector(deleteBtnClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:deleteBtn];
} - (void)writeBtnClicked
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"千锋教育" forKey:@"key"];
[defaults synchronize];
} - (void)deleteBtnClicked
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:@"key"];
[defaults synchronize];
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
UI2_NSUserDefaults的更多相关文章
随机推荐
- LINUX 逻辑地址、线性地址、物理地址和虚拟地址 转
一.概念物理地址(physical address)用于内存芯片级的单元寻址,与处理器和CPU连接的地址总线相对应.——这个概念应该是这几个概念中最好理解的一个,但是值得一提的是,虽然可以直接把物理地 ...
- php 换行 空格分割处理
<?php function parse_specification($specification){ $rt=array(); $lines=array_filter(preg_split(& ...
- linxu,window系统
window下:net start VMwareHostdVMAuthdServiceVMUSBArbService"VMware NAT Service"VMnetDHCP #启 ...
- docker + swarm 集群
docker + swarm 集群 导读 Swarm是Docker公司在2014年12月初新发布的容器管理工具.和Swarm一起发布的Docker管理工具还有Machine以及Compose.Swar ...
- nginx1.4.6+php5.5.11+mysql5.6.17+mecache+opcache
要用到的软件:libiconv-1.13.tar.gz libmcrypt-2.5.8.tar.gz mcrypt-2.6.8.tar.gz mhash-0.9.9.9.tar.gz memcache ...
- 向linux内核版本号添加字符/为何有时会自动添加“+”号
转载:http://blog.csdn.net/adaptiver/article/details/7225980 1. 引子 编译2.6.35.7 kernel版本的时候发现,“2.6.35.7 ...
- Aggressive cows 二分不仅仅是查找
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7083 Accepted: 3522 Description Farme ...
- web 项目 布在tomcat服务器上出现的问题小记
1.mysql 安装前需要安装.net framework 框架 mysql 无法安装 最后一布,start server 服务起不来. 原因,为上一次mysql没有删除,干净,导入无法安装. ...
- json,xml,Html解析
1.json解析 javabean文件 public class TopNewsDetails { public String retcode; public Data data; public cl ...
- Android(java)学习笔记264:Android下的属性动画高级用法(Property Animation)
1. 大家好,在上一篇文章当中,我们学习了Android属性动画的基本用法,当然也是最常用的一些用法,这些用法足以覆盖我们平时大多情况下的动画需求了.但是,正如上篇文章当中所说到的,属性动画对补间动画 ...