Gowhich

Durban's Blog

1
2
3
4
5
6
7
8
9
btn.frame = CGRectMake(x, y, width, height);
[btn setTitle: @"search" forState: UIControlStateNormal];
//设置按钮上的自体的大小
//[btn setFont: [UIFont systemFontSize: 14.0]]; //这种可以用来设置字体的大小,但是可能会在将来的SDK版本中去除改方法
//应该使用
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn seBackgroundColor: [UIColor blueColor]];
//最后将按钮加入到指定视图superView
[superView addSubview: btn];

1
tvnamelabel=[[UIButton alloc]initWithFrame:CGRectMake(5,5,200,40)];

这样初始化的button,文字默认颜色是白色的,所有如果背景也是白色的话,是看不到文字的,

1
2
btn.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft ;//设置文字位置,现设为居左,默认的是居中
[btn setTitle:@“title”forState:UIControlStateNormal];// 添加文字

有些时候我们想让UIButton的title居左对齐,我们设置

1
btn.textLabel.textAlignment = UITextAlignmentLeft

是没有作用的,我们需要设置

1
btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;

但是问题又出来,此时文字会紧贴到做边框,我们可以设置

1
btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0);

使文字距离做边框保持10个像素的距离。


设置UIButton上字体的颜色设置UIButton上字体的颜色,不是用:

1
2
[btn.titleLabel setTextColor:[UIColorblackColor]];
btn.titleLabel.textColor=[UIColor redColor];

而是用:

1
[btn setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];

资源参考:http://blog.csdn.net/chengyingzhilian/article/details/8363855

xib 中, 没有对File’s Owner 的Outlets view 进行绑定, 导致在父视图中插入子视图时出错, 在IB中拖拽Files’ Owner到view, 添加绑定后, 运行成功!
总结一下创建视图和绑定的步骤:

  1. 创建控制器. File->New File->Iphone OS->Cocoa Touch Class->UIViewController subclass;

  2. 创建xib. File->New File->Iphone OS->User Interface->View XIB

  3. 绑定controller和view. 用Interface Builder打开xxx.xib, 点击Files’ Owner, 在Identity Inspector里面的Class Identity, 选择Step 1创建的控制器类, 接着拖拽File’s Owner到View中, 选择Outlets->view.先选中file’s owner(这个很重要)

最近服务器空间总是越来越小,找不到原因,其中有一项是这样的

1
114648472	/var/spool/clientmqueue

始终不知道这个是什么文件,经过搜索,是一个与cron有关的文件

这篇文章是这样的解决方案也给了,贴到下面


一,问题现象:
linux操作系统中的/var/spool/clientmqueue/目录下存在大量文件。
原因分析:系统中有用户开启了cron,而cron中执行的程序有输出内容,输出内容会以邮件形式发给cron的用户,而sendmail没有启动所以就产生了这些文件;
解决办法: 1、 将crontab里面的命令后面加上> /dev/null 2>&1

二,知识点:

  • 2>:重定向错误。
  • 2>&1:把错误重定向到输出要送到的地方。即把上述命令的执行结果重定向到/dev/null,即抛弃,同时,把产生的错误也抛弃。

三,具体代码:

(1)、# crontab -u cvsroot -l

1
2
01 01 * * * /opt/bak/backup  
01 02 * * * /opt/bak/backup2

(2)、# vi /opt/bak/backup

1
2
3
#!/bin/sh  
cd /
getfacl -R repository > /opt/bak/backup.acl

(3)、# vi /opt/bak/backup2

1
2
3
#!/bin/sh  
week=`date +%w`
tar zcvfp /opt/bak/cvs$week/cvs.tar.gz /repository >/dev/null 2>&1

四,清除/var/spool/clientmqueue/目录下的文件:

1
2
# cd /var/spool/clientmqueue  
# rm -rf \*

如果文件太多,占用空间太大,用上面命令删除慢的话,就执行下面的命令:

1
2
# cd /var/spool/clientmqueue  
# ls | xargs rm -f

话说删除这个大文件还是有说法的,接着下面看

rm 有最大一次刪除的數量,所以當一個目錄裡有太多的檔案或目錄時,就會出現錯誤,小弟試過應該是在二萬以下,而使用 find ./ | xargs rm -rf 的目的是先使用 find 列出檔案,再導向到 xargs,xargs 再喂給 rm,在這裡,xargs 會分批依照 rm 的最大數量餵給 rm,然後就可以順利刪除檔案了

还举了一个实例

mk-file.sh的代码如下:

1
2
3
4
5
#!/bin/bash
for ((i=0;i<20000;i++))
do
echo "This file id is $i." > test-file-${i};
done

(這個 shell script 會有目錄下產生 20000 個檔案。)
接下來來做個小小測試:

1
root # mkfile.sh

會產生 20000 個小檔案,名稱為 test-file-{1~19999}
直接使用 rm 去刪除:

1
root # rm -rf test-file-*

-bash: /bin/rm: Argument list too long (會回應引數過長的訊息)
该搭配 find 來刪除

1
root # find ./ -iname 'test-file-*' | xargs rm -rf

這樣就順利被刪除了。

如何修改导航栏的返回按钮内容,开始我也费了好久的时间最后打算自定义一个算了,结果方法还是被我找到了。

导航的返回按钮的加载原理是这样的:

1、如果B视图有一个自定义的左侧按钮(leftBarButtonItem),则会显示这个自定义按钮;
2、如果B没有自定义按钮,但是A视图的backBarButtonItem属性有自定义项,则显示这个自定义项;
3、如果前2条都没有,则默认显示一个后退按钮,后退按钮的标题是A视图的标题。
按照这个解释,我把UIBarButtonItem *backItem……这段代码放在A视图的pushViewController语句之前。

实现过程是这样的

A视图的代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];

UIBarButtonItem *returnButtonItem = [[UIBarButtonItem alloc] init];
returnButtonItem.title = @"返回";
self.navigationItem.backBarButtonItem = returnButtonItem;

if(row == 2)
{
personViewController *person = [[personViewController alloc] initWithNibName:@"personViewController" bundle:nil];
[self.navigationController pushViewController:person animated:YES];
}

if(row == 3)
{
teleplayViewController *teleplay = [[teleplayViewController alloc] initWithNibName:@"teleplayViewController" bundle:nil];
[self.navigationController pushViewController:teleplay animated:YES];
}
}

注意这段代码:

1
2
3
UIBarButtonItem *returnButtonItem = [[UIBarButtonItem alloc] init];
returnButtonItem.title = @"返回";
self.navigationItem.backBarButtonItem = returnButtonItem;

B视图我是什么也没有做的。结果就达到你想要的效果了。

查资料的时候有一种新的方法,没有试过,先帖在这里了:

1
2
3
4
self.navigationController.navigationBar.topItem.title=self.message;
self.navigationController.navigationBar.tintColor=[UIColorblackColor];
UIBarButtonItem*backButton = [[UIBarButtonItemalloc] initWithTitle:@" fan hui "style:UIBarButtonItemStyleBorderedtarget:selfaction:@selector(PopViewController)];
self.navigationItem.leftBarButtonItem= backButton;

这个应该是贴在B视图里面(就是你要跳转到的视图)

补充

对于这段代码:

1
2
3
UIBarButtonItem *returnButtonItem = [[UIBarButtonItem alloc] init];
returnButtonItem.title = @"返回";
self.navigationItem.backBarButtonItem = returnButtonItem;

很好解释的,事实上也不用一定要放在我说的那里,也是可以放在 viewWillAppear里面的

1
2
3
4
5
6
-(void) viewWillAppear:(BOOL)animated
{
UIBarButtonItem *returnButtonItem = [[UIBarButtonItem alloc] init];
returnButtonItem.title = @"返回";
self.navigationItem.backBarButtonItem = returnButtonItem;
}

这两个方法区别就是一个可以copy后是可变的,一个是不可变的

我举个例子,代码如下:

1
2
@property (strong, nonatomic) NSMutableDictionary *dataDic;
@property (strong, nonatomic) NSMutableDictionary *showDataDic;

我要copy dataDic到showDataDic里面去

第一种方法:

1
2
self.showDataDic = [NSMutableDictionary dictionaryWithCapacity:20];
self.showDataDic = [self.dataDic copy];

这样的话self.showDataDic是不可变的

第二种方法:

1
2
self.showDataDic = [NSMutableDictionary dictionaryWithCapacity:20];
self.showDataDic = [self.dataDic mutableCopy];

这样的话self.showDataDic是可变的

在iOS6中,statusbar的颜色是由当前页面的UINavigationBar决定的,也就是当前view中的UINavigationBar决定statusbar的tintColor的。如果我们的UIViewController是UINavigationController的子集,那么就好statusbar的颜色还好设置,如果UINavigationBar被hide掉,或是根本就没有UINavigationController,那么在iOS6上statusbar的颜色就是黑色。
如何办呢?我们如何才能在iOS6上设置statusbar的颜色?
刚才说了,statusbar的颜色是由UINavigationBar决定的,那么我们可不可以在当前view中放一个UINavigationBar并设置其颜色,影响其statusbar的颜色。 我们的假设是正确的,这个方法的确可行。

在我们的view中放入一个UINavigationBar,并设置其frame=CGRectMake(0, -43, 320, 44);

在这儿y的值一定得是-43(UINavigationBar有一个像素的值),不然一样达不到效果。

实例代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
- (void)viewDidLoad
{
[super viewDidLoad];
self.personSearch.delegate = self;
self.dataTable.delegate = self;
self.dataTable.dataSource = self;


//设置状态栏的颜色为红色
UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, -43.0, 320, 44)];
navigationBar.tintColor = [UIColor redColor];
[self.view addSubview:navigationBar];
}

我的情况是这样子的,由于我要远程获取数据然后呈现数据,但是首先我获取的远程数据是json格式的,然后我移动端将其转换为字典类型。

出问题的代码如下:

我在.h文件中这样的

1
@property (strong, nonatomic) NSMutableDictionary *dataDic;

我在.m文件中这样的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-(void) initData
{
NSDate *date = [NSDate date];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSString *dateString = [dateFormatter stringFromDate: [NSDate dateWithTimeInterval:-(2 * 24 * 60 * 60) sinceDate:date]];

NSString *urlString = @"http://xxx.xxx.xxx.xxx:xxxxxxxxxx/xxxxx/xxxxxx?";
urlString = [urlString stringByAppendingFormat:@"order_by=%@",@"index"];
urlString = [urlString stringByAppendingFormat:@"&start_date=%@",dateString];
urlString = [urlString stringByAppendingFormat:@"&end_date=%@",dateString];
urlString = [urlString stringByAppendingFormat:@"&start=%@",@"1"];
urlString = [urlString stringByAppendingFormat:@"&offset=%@",@"20"];
urlString = [urlString stringByAppendingFormat:@"&app_key=%@",@""];


NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60];

NSURLResponse *response = [[NSURLResponse alloc] init];
NSError *receiveDataError = [[NSError alloc] init];

NSMutableData *receivedData = (NSMutableData *)[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&receiveDataError];

if(receivedData == nil)
{
NSLog(@"获取数据失败");
}


NSError *jsonError = [[NSError alloc] init];
NSDictionary *personDictionary = [NSJSONSerialization JSONObjectWithData:receivedData
options:NSJSONReadingMutableContainers
error:&jsonError];
NSMutableDictionary *personInfo = [personDictionary objectForKey:@"data"];

NSMutableDictionary *personList = [personInfo objectForKey:@"list"];

// self.dataDic = [NSMutableDictionary dictionaryWithCapacity:20];

if([personList isKindOfClass:[NSMutableArray class]])
{
int i = 0;
for (NSDictionary *dic in personList) {
[self.dataDic setObject:dic forKey:[NSString stringWithFormat:@"%d",i]];
i++;
}
}


if([personList isKindOfClass:[NSMutableDictionary class]])
{
NSLog(@"NSMutableDictionary 类");
}

NSLog(@"self.dataDic = %@",self.dataDic);
}

运行后,输出的结果如下:

1
2013-05-29 09:54:53.460 vlinkagePerson3[6359:907] self.dataDic = (null)

很奇怪,为什么结果为空呢,于是经过查找资料并进行尝试修改,结果就可以了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-(void) initData
{
NSDate *date = [NSDate date];

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSString *dateString = [dateFormatter stringFromDate: [NSDate dateWithTimeInterval:-(2 * 24 * 60 * 60) sinceDate:date]];

NSString *urlString = @"http://xxx.xxx.xxx.xxx:xxxxxxxxxx/xxxxx/xxxxxx?";
urlString = [urlString stringByAppendingFormat:@"order_by=%@",@"index"];
urlString = [urlString stringByAppendingFormat:@"&start_date=%@",dateString];
urlString = [urlString stringByAppendingFormat:@"&end_date=%@",dateString];
urlString = [urlString stringByAppendingFormat:@"&start=%@",@"1"];
urlString = [urlString stringByAppendingFormat:@"&offset=%@",@"20"];
urlString = [urlString stringByAppendingFormat:@"&app_key=%@",@""];


NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60];

NSURLResponse *response = [[NSURLResponse alloc] init];
NSError *receiveDataError = [[NSError alloc] init];

NSMutableData *receivedData = (NSMutableData *)[NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&receiveDataError];

if(receivedData == nil)
{
NSLog(@"获取数据失败");
}


NSError *jsonError = [[NSError alloc] init];
NSDictionary *personDictionary = [NSJSONSerialization JSONObjectWithData:receivedData
options:NSJSONReadingMutableContainers
error:&jsonError];
NSMutableDictionary *personInfo = [personDictionary objectForKey:@"data"];

NSMutableDictionary *personList = [personInfo objectForKey:@"list"];

self.dataDic = [NSMutableDictionary dictionaryWithCapacity:20];

if([personList isKindOfClass:[NSMutableArray class]])
{
int i = 0;
for (NSDictionary *dic in personList) {
[self.dataDic setObject:dic forKey:[NSString stringWithFormat:@"%d",i]];
i++;
}
}


if([personList isKindOfClass:[NSMutableDictionary class]])
{
NSLog(@"NSMutableDictionary 类");
}

NSLog(@"self.dataDic = %@",self.dataDic);
}

关键一点是这里self.dataDic = [NSMutableDictionary dictionaryWithCapacity:20];应该是没有分配空间吧

判断对象类型1

-(BOOL) isKindOfClass: classObj 判断是否是这个类或者这个类的子类的实例

-(BOOL) isMemberOfClass: classObj 判断是否是这个类的实例

使用方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//YES   
if ([teacher isKindOfClass:[Teacher class]]) {
NSLog(@"teacher 是 Teacher类或Teacher的子类");
}
//YES
if ([teacher isKindOfClass:[Person class]]) {
NSLog(@"teacher 是 Person类或Person的子类");
}
//YES
if ([teacher isKindOfClass:[NSObject class]]) {
NSLog(@"teacher 是 NSObject类或NSObject的子类");
}

//YES
if ([teacher isMemberOfClass:[Teacher class]]) {
NSLog(@"teacher Teacher类的成员");
}
//NO
if ([teacher isMemberOfClass:[Person class]]) {
NSLog(@"teacher Person类的成员");
}
//NO
if ([teacher isMemberOfClass:[NSObject class]]) {
NSLog(@"teacher NSObject类的成员");
}

判断对象类型2

-(BOOL) respondsToSelector: selector 判断实例是否有这样方法

+(BOOL) instancesRespondToSelector: 判断类是否有这个方法。此方法是类方法,不能用在类的对象

使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// YES   
if ( [teacher respondsToSelector: @selector( setName: )] == YES ) {
NSLog(@"teacher responds to setSize: method" );
}
// NO
if ( [teacher respondsToSelector: @selector( abcde )] == YES ) {
NSLog(@"teacher responds to nonExistant method" );
}
// YES
if ( [Teacher respondsToSelector: @selector( alloc )] == YES ) {
NSLog(@"teacher class responds to alloc method\n" );
}
// NO
if ( [Person instancesRespondToSelector: @selector(teach)] == YES ) {
NSLog(@"Person instance responds to teach method" );
}
// YES
if ( [Teacher instancesRespondToSelector: @selector(teach)] == YES ) {
NSLog(@"Teacher instance responds to teach method");
}
// YES
if ( [Teacher instancesRespondToSelector: @selector(setName:)] == YES ) {
NSLog(@"Teacher instance responds to setName: method" );
}

Objective-C的id类型

C++ 使用的是强类型:对象必须符合其类型,否则不能通过编译。在 Objective-C 中,id类型类似于(void*) ,可以指向任何类的实例。而不需要强制转换。
实例如下:

1
2
3
4
5
Person *person = [[Person alloc] init];  
Teacher *teacher = [[Teacher alloc] init];

id p = person;
id t = teacher;

使用UIScrollView的时候,总是调用不了touchesBegan和touchesEnd,还有另外的两个方法,经过查找是因为UIScrollViewDelegate没有这个方法,不过我们可以自己来定义这个方法,来调用父类的方法:

touchScrollView.h

1
2
3
4
5
6
7
8
9
10
11
12
13
//
// touchScrollView.h
// xunYi7
//
// Created by david on 13-5-28.
// Copyright (c) 2013年 david. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface touchScrollView : UIScrollView

@end

touchScrollView.m

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// touchScrollView.m
// xunYi7
//
// Created by david on 13-5-28.
// Copyright (c) 2013年 david. All rights reserved.
//

#import "touchScrollView.h"

@implementation touchScrollView

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesBegan:touches withEvent:event];
if ( !self.dragging )
{
[[self nextResponder] touchesBegan:touches withEvent:event];
}
}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[super touchesEnded:touches withEvent:event];
if ( !self.dragging )
{
[[self nextResponder] touchesEnded:touches withEvent:event];
}
}

-(void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
if(!self.dragging)
{
[[self nextResponder] touchesCancelled:touches withEvent:event];
}
}

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
if(!self.dragging)
{
[[self nextResponder] touchesMoved:touches withEvent:event];
}
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/

@end

使用方法可以这样

1
@property (strong, nonatomic) IBOutlet touchScrollView *scrollView;

创建或初始化可用以下方法

用于创建NSDate实例的类方法有

  • + (id)date;
    返回当前时间

  • + (id)dateWithTimeIntervalSinceNow:(NSTimeInterval)secs;
    返回以当前时间为基准,然后过了secs秒的时间,这里的值可以为负值

  • + (id)dateWithTimeIntervalSinceReferenceDate:(NSTimeInterval)secs;
    返回以2001/01/01 GMT为基准,然后过了secs秒的时间,这里的值可以为负值

  • + (id)dateWithTimeIntervalSince1970:(NSTimeInterval)secs;
    返回以1970/01/01 GMT为基准,然后过了secs秒的时间,这里的值可以为负值

  • + (id)distantFuture;
    返回很多年以后的未来的某一天。(比如你需要一个比现在(Now)晚(大)很长时间的时间值,则可以调用该方法。测试返回了4000/12/31 16:00:00)

  • + (id)distantPast;
    返回很多年以前的某一天。(比如你需要一个比现在(Now)早(小)大很长时间的时间值,则可以调用该方法。测试返回了公元前0001/12/31 17:00:00)

用于创建NSDate实例的实例方法有

  • - (id)addTimeInterval:(NSTimeInterval)secs;
    返回以目前的实例中保存的时间为基准,然后过了secs秒的时间,这里的值可以为负值

用于初始化NSDate实例的实例方法有

  • - (id)init;
    初始化为当前时间。类似date方法
    初始化为以2001/01/01 GMT为基准,然后过了secs秒的时间。类似dateWithTimeIntervalSinceReferenceDate:方法

  • - (id)initWithTimeInterval:(NSTimeInterval)secs sinceDate:(NSDate *)refDate;
    初始化为以refDate为基准,然后过了secs秒的时间,这里的值可以为负值

  • - (id)initWithTimeIntervalSinceNow:(NSTimeInterval)secs;
    初始化为以当前时间为基准,然后过了secs秒的时间,这里的值可以为负值

日期之间比较可用以下方法

  • - (BOOL)isEqualToDate:(NSDate *)otherDate;
    与otherDate比较,相同返回YES

  • - (NSDate *)earlierDate:(NSDate *)anotherDate;
    与anotherDate比较,返回较早的那个日期

  • - (NSDate *)laterDate:(NSDate *)anotherDate;
    与anotherDate比较,返回较晚的那个日期

  • - (NSComparisonResult)compare:(NSDate *)other;
    该方法用于排序时调用:

  • 当实例保存的日期值与anotherDate相同时返回NSOrderedSame

  • 当实例保存的日期值晚于anotherDate时返回NSOrderedDescending

  • 当实例保存的日期值早于anotherDate时返回NSOrderedAscending

取回时间间隔可用以下方法

  • - (NSTimeInterval)timeIntervalSinceDate:(NSDate \*)refDate;
    以refDate为基准时间,返回实例保存的时间与refDate的时间间隔

  • - (NSTimeInterval)timeIntervalSinceNow;
    以当前时间(Now)为基准时间,返回实例保存的时间与当前时间(Now)的时间间隔

  • - (NSTimeInterval)timeIntervalSince1970;
    以1970/01/01 GMT为基准时间,返回实例保存的时间与1970/01/01 GMT的时间间隔

  • - (NSTimeInterval)timeIntervalSinceReferenceDate;
    以2001/01/01 GMT为基准时间,返回实例保存的时间与2001/01/01 GMT的时间间隔

  • + (NSTimeInterval)timeIntervalSinceReferenceDate;
    以2001/01/01 GMT为基准时间,返回当前时间(Now)与2001/01/01 GMT的时间间隔

将时间表示成字符串

  • - (NSString *)description;
    以YYYY-MM-DD HH:MM:SS ±HHMM的格式表示时间。(其中 “±HHMM” 表示与GMT的存在多少小时多少分钟的时区差异。比如,若时区设置在北京,则 “±HHMM” 显示为 “+0800”)
0%