- 博客(27)
- 收藏
- 关注
转载 Objective-C 中的 Meta-class
在这篇文章中,我关注的是 Objective-C 中的一个陌生的概念—— meta-class。在 Objective-C 中的每个类都有一个相关联的 meta-class,但是你很少会直接使用 meta-class,他们仍旧保持着神秘的面纱。我们从在运行时创建一个类开始。通过查看 “class pair”,我会解释 meta-class 是什么,同时也会谈谈在 Objective-C 中的对象或
2014-04-26 13:05:01 542
转载 @class SEL IMP
在objective c中,如果细心的话会发现,每个类中都会自动生成一个class 类型的isa,[plain] view plaincopy@interface NSObject { Class isa; } isa是什么,class又是什么呢,找到Class的定义我们会发现如下:
2014-04-26 13:04:15 615
转载 CoreData 轻量数据升级
如果IOS App 使用到CoreData,并且在上一个版本上有数据库更新(新增表、字段等操作),那在覆盖安装程序时就要进行CoreData数据库的迁移,具体操作如下:1.选中你的mydata.xcdatamodeld文件,选择菜单editor->Add Model Version 比如取名:mydata2.xcdatamodel2.设置当前版本
2014-04-26 00:35:10 662
原创 NSArray 查询数组中的对象
1.NSString 对象NSArray *array =@["123", @"234" , @"345"];NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF contains [cd] %@", "2"];NSArray *filterdArray = [array filterdArrayUsingP
2014-04-22 23:03:17 7683
原创 Predicate 查询数组中的字典对象
NSString *firstName = @"Ben";NSArray *array = @[ @{ @"lastName" : "Turner" }, @{ @"firstName" : @"Ben", @"lastName" : @"Ballard", @"birthday", [NSDate d
2014-04-22 09:50:09 3126
转载 UICollectionView详解_2
1.1. Collection View全家福:UICollectionView, UITableView, NSCollectionViewn 不直接等效于NSCollectionViewn 也不替代UITableView----亲兄弟 为什么要使用Collection Views呢?n 可以高度定制内容的展现n 管理数据最佳的做法n 即使是处理
2014-04-20 11:10:03 10349 1
转载 IOS CoreData 多表查询demo解析(三)--查询
1、查询 HR 部门的张三 //查询 开发部门中张三的工资等级 NSLog(@"----------查询 开发部门中张三的工资等级----------"); NSLog(@"----------第1种方法----------"); //第1种方法 NSEntityDescription * emEty = [NSEntityDescription
2014-04-17 23:16:21 743
转载 IOS CoreData 多表查询(上)
在网上搜索了下,发现只有部分讲解CoreData关系的,但对多表之间的查询并没有相应的介绍。因此操作自己写了个。先创建几个表。1、部门表:department dp_id Integer primary key dp_deptname varchar(20) //使用coredata实体创建时用string就行图:
2014-04-17 23:12:27 714
转载 IOS CoreData 多表查询(上)
在IOS CoreData中,多表查询上相对来说,没有SQL直观,但COREDATA的功能还是可以完成相关操作的。多表查询,表与表之间肯定存在某种关系,如果对于类似外连接,左连接等操作,在COREDATA中就显得无力(请高手指教了)。在上节中,介绍了一下数据库的关系查询操作。下面使用CoreData进行关系数据库的表与表之间的关系演示。生成COREDATA和如何设置
2014-04-17 23:11:32 643
原创 得到UUID
+ (NSString *)makeUUID { CFUUIDRef uuidRef = CFUUIDCreate(NULL); CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef); CFRelease(uuidRef); NSString* uuid = [NSString stringWithString:
2014-04-16 17:30:42 872
转载 ios 学习之 NSPredicate 模糊、精确、查询
简述:Cocoa框架中的NSPredicate用于查询,原理和用法都类似于SQL中的where,作用相当于数据库的过滤取。定义(最常用到的方法):[cpp] view plaincopyNSPredicate *ca = [NSPredicate predicateWithFormat:(NSString *), ...]
2014-04-11 10:31:06 685
转载 Objective-C在ARC下结合GCD的单例模式和宏模版
单例模式在iOS开发过程中经常用到,苹果提供过objective c单例的比较官方的写法:[cpp] view plaincopystatic MyGizmoClass *sharedGizmoManager = nil; + (MyGizmoClass*)sharedManager { @synchron
2014-04-10 16:40:01 623
转载 Core Foundation 对象不属于ARC的管辖范围
我们先来看一下ARC无效的时辰,我们写id类型转void*类型的写法:12id obj = [[NSObject alloc] init];void *p = obj;反过来,当把void*对象变回id类型时,只是简单地如下来写,12id obj = p;[obj release];
2014-04-10 00:24:59 1645
原创 ARC Rules
RulesTo write and compile source code for ARC, you have to take care of a few things. Justby following the rules in the list below, you can write source code for an ARC-enabledenvironment with confi
2014-04-09 19:10:14 725
原创 __weak 注意事项
id __weak obj = [[NSObject alloc] init];The variable obj is qualified with __weak. When the source code is compiled, the compiler shows a warning message.warning: assigning retained obj to weak va
2014-04-09 18:09:23 1163
原创 rules for reference counting are still fulfilled(ARC).
Please note that the following rules for reference counting are still fulfilled(ARC). You have ownership of any objects you create. You can take ownership of an object using retain. When
2014-04-09 17:58:36 723
原创 ARC How the strong reference works
How the strong reference worksid __strong obj0 = [[NSObject alloc] init];/** obj0 has a strong reference to object A*/id __strong obj1 = [[NSObject alloc] init];/** obj1 has a strong refer
2014-04-09 17:30:22 865
转载 ASIHTTPRequest系列(一):同步和异步请求
SIHTTPRequest项目地址: http://github.com/pokeb/asi-http-request/tree ,关于ASIHTTPRequest到底是什么,你可以在项目首页看到。它提供如下功能:提交数据到web服务器或者从web服务器获得数据;下载数据到内存或磁盘;采用html input相同的机制上传文件;断点续传;简单存取HTTP头;上传/下载进
2014-04-09 15:55:50 551
转载 ASIHTTPRequest系列(二):文件下载
四、下载1、简单下载打开IB,拖入一个Progress View,在源文件中声明为IBOutlet,然后进行连接。-( IBAction )goURL{NSString * path=[ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory ,NSUserDomainMask , YES ) objectAtIndex
2014-04-09 15:54:01 492
转载 ASIHTTPRequest系列(三):文件上传
五、文件上传1、服务端文件上传需要服务端的配合。我们可在本机搭建tomcat测试环境。关于tomcat在MacOSX下的安装配置,参考作者另一博文《安装Tomcat到Mac OSX》。打开Eclipse,新建web工程。在其中新建一个ServletUploadServlet:import java.io.*;import java.util.*; importjavax
2014-04-09 15:51:53 560
转载 ASIHTTPRequest系列(四):Cookies
Cookies 是重要的服务器状态保持策略。Web 服务器常使用 Cookies 技术来实现用户免登录功能和存储用户状态信息。ASIHTTPRequest 支持客户端 Cookies 的存取。1、服务器端Session 是服务器端技术,虽然 Cookies 是保存在客户端的。因此我们需要一个服务器端环境。打开 Eclipse,新建 Web 工程,随便写几个简单的 jsp 页面: pag
2014-04-09 15:48:59 549
转载 ASINetworkQueue使用cancelAllOperations方法来取消下载时使用的注意点 在 ASIHTTPRequest V1.7前提下 正确使用: imgDataDownLo
ASINetworkQueue使用cancelAllOperations方法来取消下载时使用的注意点在 ASIHTTPRequest V1.7前提下正确使用: imgDataDownLoadQueue = [[ASINetworkQueue alloc] init]; [imgDataDownLoadQueue setShouldCancelAllReq
2014-04-08 17:02:50 1273
原创 dispatch_once implement 单例
+ (id)shareInstance{static id shareInstance = nil;static dispatch_once_t onceToken;dispatch_once(&onceToken, {shareInstance = [ [ [self class ] alloc ]init ];});return shareInstance
2014-04-07 14:23:00 904
原创 多用GCD,少用PerformSelector
For example, to perform a task after a delay, you should prefer the latter to theformer:// Using performSelector:withObject:afterDelay:[self performSelector:@selector(doSomething)withObject:ni
2014-04-06 23:59:40 997
原创 NSCache
//NSCache使用#import // Network fetcher classtypedef void(^EOCNetworkFetcherCompletionHandler)(NSData *data);@interface EOCNetworkFetcher : NSObject- (id)initWithURL:(NSURL*)url;- (void)
2014-04-06 14:10:15 6001
转载 ios email 验证规则
#pragma mark - email 验证规则-(BOOL)isValidateEmail:(NSString *)email{ NSString *emailRegex =@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailPredicate = [NSPre
2014-04-03 15:39:45 1531
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人