Skip to content

Instantly share code, notes, and snippets.

@helloworld116
helloworld116 / DateStringTransform.m
Created March 11, 2013 05:21
oc:transform:日期时间相关
//返回YYYY-MM-DD HH:MM:SS格式的当前时间
+(NSString *)getCurrentTime{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
return [dateFormatter stringFromDate:[NSDate date]];
}
//如果信息发表在1小时之前显示分钟,一天之内的信息显示小时,10天之内按天显示,10天之外按所发表时间进行显示:
+ (NSString *)intervalSinceNow: (NSString *) theDate
{
//objective-c使用正则表达式验证邮箱
+ (BOOL)isEmailAddress:(NSString*)email {
NSString *emailRegex = @"^\\w+((\\-\\w+)|(\\.\\w+))*@[A-Za-z0-9]+((\\.|\\-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:email];
}
@helloworld116
helloworld116 / JsonKit.m
Created March 11, 2013 05:04
ios:json:ios5自带API处理json
//
// NSDictionary+JSONCategories.h
// ShopCloth
//
// Created by apple on 12-12-7.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "AppDelegate.h"
@helloworld116
helloworld116 / AsynLoadData.m
Created March 11, 2013 03:50
ios:异步加载数据主要流程代码
//1显示状态
[SVProgressHUD showWithStatus:@"正在载入..."];
//2从系统中获取一个并行队列
dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//3在后台线程创建图像选择器
dispatch_async(concurrentQueue, ^{
NSDictionary* data = [NSDictionary dictionaryWithContentsOfJSONURLString:kUrlOfBookComments];
//4让主线程显示图像选择器
dispatch_async(dispatch_get_main_queue(), ^{
self.loadFooterView = [[LoadingMoreFooterView alloc]initWithFrame:CGRectZero];
@helloworld116
helloworld116 / SVProgressHUD.m
Created March 11, 2013 03:28
ios:customcontrol:SVProgressHUD:页面切换等场景下显示程序当前运行状态
//下载路径 https://github.com/samvermette/SVProgressHUD
//
// SVProgressHUDViewController.m
// SVProgressHUD
//
// Created by Sam Vermette on 27.03.11.
// Copyright 2011 Sam Vermette. All rights reserved.
//
//SVProgressHUD使用范例
@helloworld116
helloworld116 / Toast.m
Created March 11, 2013 03:07
ios:customcontrol:模仿Android中的Toast
//
// Toast.h
// UCBook
//
// Created by apple on 13-1-22.
// Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//
#define DEFAULT_DISPLAY_DURATION 2.0f
@helloworld116
helloworld116 / StrikeLabel.m
Created March 11, 2013 02:57
ios:customcontrols:文字中间带条线条
//
// StrikeLabel.h
// UCBook
//
// Created by apple on 13-1-23.
// Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@helloworld116
helloworld116 / SqlUtils.m
Created March 11, 2013 02:48
oc:sqlite3_demo
//
// SqlUtils.m
// UCBook
//
// Created by apple on 13-1-15.
// Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//
#import "SqlUtils.h"
#import "CommonUtils.h"
@helloworld116
helloworld116 / HelloWorld.m
Created March 9, 2013 08:01
objective-c:the first pro
jwaoeifjioewajfiowjaefiojwaiejf
wjfeaoijewaoifjowiajf
jwaeofijeoiwajfoiewajf