- 浏览: 765539 次
- 性别:
- 来自: 大连
文章分类
- 全部博客 (417)
- ASP.NET MVC (18)
- WEB基础 (24)
- 数据库 (69)
- iPhone (20)
- JQuery (3)
- Android (21)
- UML (8)
- C# (32)
- 移动技术 (19)
- 条码/RFID (6)
- MAC (8)
- VSS/SVN (6)
- 开卷有益 (4)
- 应用软件 (1)
- 软件工程 (1)
- java/Eclipse/tomcat (61)
- 英语学习 (2)
- 综合 (16)
- SharePoint (7)
- linux (42)
- Solaris/Unix (38)
- weblogic (12)
- c/c++ (42)
- 云 (1)
- sqlite (1)
- FTp (2)
- 项目管理 (2)
- webservice (1)
- apache (4)
- javascript (3)
- Spring/Struts/Mybatis/Hibernate (4)
- 航空业务 (1)
- 测试 (6)
- BPM (1)
最新评论
-
dashengkeji:
1a64f39292ebf4b4bed41d9d6b21ee7 ...
使用POI生成Excel文件,可以自动调整excel列宽等(转) -
zi_wu_xian:
PageOffice操作excel也可以设置表格的行高列宽,并 ...
使用POI生成Excel文件,可以自动调整excel列宽等(转) -
wanggang0321:
亲,我在pptx(office2007以上版本)转pdf的时候 ...
JODConverter]word转pdf心得分享(转) -
xiejanee:
楼主:你好!我想请问下 你在代码中用DOMDocument* ...
Xerces-C++学习之——查询修改XML文档 (转)
http://www.cnblogs.com/phonlin/articles/1941478.html
/*******************************************************************************************
NSString
*******************************************************************************************/
//一、NSString
/*----------------创建字符串的方法----------------*/
//1、创建常量字符串。
NSString *astring = @"This is a String!";
//2、创建空字符串,给予赋值。
NSString *astring = [[NSString alloc] init];
astring = @"This is a String!";
[astring release];
NSLog(@"astring:%@",astring);
//
NSString *astring = [[NSString alloc] init];
NSLog(@"0x%.8x", astring);
astring=@"This is a String!";
NSLog(@"0x%.8x", astring);
[astring release];
NSLog(@"astring:%@",astring);
//3、在以上方法中,提升速度:initWithString方法
NSString *astring = [[NSString alloc] initWithString:@"This is a String!"];
NSLog(@"astring:%@",astring);
[astring release];
//4、用标准c创建字符串:initWithCString方法
char *Cstring = "This is a String!";
NSString *astring = [[NSString alloc] initWithCString:Cstring];
NSLog(@"astring:%@",astring);
[astring release];
//5、创建格式化字符串:占位符(由一个%加一个字符组成)
int i = 1;
int j = 2;
NSString *astring = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%d.This is %i string!",i,j]];
NSLog(@"astring:%@",astring);
[astring release];
//6、创建临时字符串
NSString *astring;
astring = [NSString stringWithCString:"This is a temporary string"];
NSLog(@"astring:%@",astring);
/*----------------从文件读取字符串:initWithContentsOfFile方法----------------*/
NSString *path = @"astring.text";
NSString *astring = [[NSString alloc] initWithContentsOfFile:path];
NSLog(@"astring:%@",astring);
[astring release];
/*----------------写字符串到文件:writeToFile方法----------------*/
NSString *astring = [[NSString alloc] initWithString:@"This is a String!"];
NSLog(@"astring:%@",astring);
NSString *path = @"astring.text";
[astring writeToFile: path atomically: YES];
[astring release];
/*----------------比较两个字符串----------------*/
//用C比较:strcmp函数
char string1[] = "string!";
char string2[] = "string!";
if(strcmp(string1, string2) = = 0)
{
NSLog(@"1");
}
//isEqualToString方法
NSString *astring01 = @"This is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 isEqualToString:astring02];
NSLog(@"result:%d",result);
//compare方法(comparer返回的三种值)
NSString *astring01 = @"This is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 compare:astring02] = = NSOrderedSame;
NSLog(@"result:%d",result);
//NSOrderedSame判断两者内容是否相同
NSString *astring01 = @"This is a String!";
NSString *astring02 = @"this is a String!";
BOOL result = [astring01 compare:astring02] = = NSOrderedAscending;
NSLog(@"result:%d",result);
//NSOrderedAscending判断两对象值的大小(按字母顺序进行比较,astring02大于astring01为真)
NSString *astring01 = @"this is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 compare:astring02] = = NSOrderedDescending;
NSLog(@"result:%d",result);
//NSOrderedDescending判断两对象值的大小(按字母顺序进行比较,astring02小于astring01为真)
//不考虑大小写比较字符串1
NSString *astring01 = @"this is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 caseInsensitiveCompare:astring02] = = NSOrderedSame;
NSLog(@"result:%d",result);
//NSOrderedDescending判断两对象值的大小(按字母顺序进行比较,astring02小于astring01为真)
//不考虑大小写比较字符串2
NSString *astring01 = @"this is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 compare:astring02
options:NSCaseInsensitiveSearch | NSNumericSearch] = = NSOrderedSame;
NSLog(@"result:%d",result);
//NSCaseInsensitiveSearch:不区分大小写比较 NSLiteralSearch:进行完全比较,区分大小写 NSNumericSearch:比较字符串的字符个数,而不是字符值。
/*----------------改变字符串的大小写----------------*/
NSString *string1 = @"A String";
NSString *string2 = @"String";
NSLog(@"string1:%@",[string1 uppercaseString]);//大写
NSLog(@"string2:%@",[string2 lowercaseString]);//小写
NSLog(@"string2:%@",[string2 capitalizedString]);//首字母大小
/*----------------在串中搜索子串----------------*/
NSString *string1 = @"This is a string";
NSString *string2 = @"string";
NSRange range = [string1 rangeOfString:string2];
int location = range.location;
int leight = range.length;
NSString *astring = [[NSString alloc] initWithString:[NSString stringWithFormat:@"Location:%i,Leight:%i",location,leight]];
NSLog(@"astring:%@",astring);
[astring release];
/*----------------抽取子串 ----------------*/
//-substringToIndex: 从字符串的开头一直截取到指定的位置,但不包括该位置的字符
NSString *string1 = @"This is a string";
NSString *string2 = [string1 substringToIndex:3];
NSLog(@"string2:%@",string2);
//-substringFromIndex: 以指定位置开始(包括指定位置的字符),并包括之后的全部字符
NSString *string1 = @"This is a string";
NSString *string2 = [string1 substringFromIndex:3];
NSLog(@"string2:%@",string2);
//-substringWithRange: //按照所给出的位置,长度,任意地从字符串中截取子串
NSString *string1 = @"This is a string";
NSString *string2 = [string1 substringWithRange:NSMakeRange(0, 4)];
NSLog(@"string2:%@",string2);
//扩展路径
NSString *Path = @"~/NSData.txt";
NSString *absolutePath = [Path stringByExpandingTildeInPath];
NSLog(@"absolutePath:%@",absolutePath);
NSLog(@"Path:%@",[absolutePath stringByAbbreviatingWithTildeInPath]);
//文件扩展名
NSString *Path = @"~/NSData.txt";
NSLog(@"Extension:%@",[Path pathExtension]);
/*******************************************************************************************
NSMutableString
*******************************************************************************************/
/*---------------给字符串分配容量----------------*/
//stringWithCapacity:
NSMutableString *String;
String = [NSMutableString stringWithCapacity:40];
/*---------------在已有字符串后面添加字符----------------*/
//appendString: and appendFormat:
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
//[String1 appendString:@", I will be adding some character"];
[String1 appendFormat:[NSString stringWithFormat:@", I will be adding some character"]];
NSLog(@"String1:%@",String1);
*/
/*--------在已有字符串中按照所给出范围和长度删除字符------*/
/*
//deleteCharactersInRange:
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 deleteCharactersInRange:NSMakeRange(0, 5)];
NSLog(@"String1:%@",String1);
/*--------在已有字符串后面在所指定的位置中插入给出的字符串------*/
//-insertString: atIndex:
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 insertString:@"Hi! " atIndex:0];
NSLog(@"String1:%@",String1);
/*--------将已有的空符串换成其它的字符串------*/
//-setString:
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 setString:@"Hello Word!"];
NSLog(@"String1:%@",String1);
/*--------按照所给出的范围,和字符串替换的原有的字符------*/
//-setString:
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 replaceCharactersInRange:NSMakeRange(0, 4) withString:@"That"];
NSLog(@"String1:%@",String1);
/*-------------判断字符串内是否还包含别的字符串(前缀,后缀)-------------*/
//01:检查字符串是否以另一个字符串开头- (BOOL) hasPrefix: (NSString *) aString;
NSString *String1 = @"NSStringInformation.txt";
[String1 hasPrefix:@"NSString"] = = 1 ? NSLog(@"YES") : NSLog(@"NO");
[String1 hasSuffix:@".txt"] = = 1 ? NSLog(@"YES") : NSLog(@"NO");
//02:查找字符串某处是否包含其它字符串 - (NSRange) rangeOfString: (NSString *) aString,这一点前面在串中搜索子串用到过;
/*******************************************************************************************
NSArray
*******************************************************************************************/
/*---------------------------创建数组------------------------------*/
//NSArray *array = [[NSArray alloc] initWithObjects:
@"One",@"Two",@"Three",@"Four",nil];
self.dataArray = array;
[array release];
//- (unsigned) Count;数组所包含对象个数;
NSLog(@"self.dataArray cound:%d",[self.dataArray count]);
//- (id) objectAtIndex: (unsigned int) index;获取指定索引处的对象;
NSLog(@"self.dataArray cound 2:%@",[self.dataArray objectAtIndex:2]);
/*--------------------------从一个数组拷贝数据到另一数组(可变数级)----------------------------*/
//arrayWithArray:
//NSArray *array1 = [[NSArray alloc] init];
NSMutableArray *MutableArray = [[NSMutableArray alloc] init];
NSArray *array = [NSArray arrayWithObjects:
@"a",@"b",@"c",nil];
NSLog(@"array:%@",array);
MutableArray = [NSMutableArray arrayWithArray:array];
NSLog(@"MutableArray:%@",MutableArray);
array1 = [NSArray arrayWithArray:array];
NSLog(@"array1:%@",array1);
//Copy
//id obj;
NSMutableArray *newArray = [[NSMutableArray alloc] init];
NSArray *oldArray = [NSArray arrayWithObjects:
@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",nil];
NSLog(@"oldArray:%@",oldArray);
for(int i = 0; i
发表评论
-
ios随笔4
2012-06-13 09:44 0<!-- [if gte mso 9]><x ... -
donghua
2012-03-15 13:11 1136iPhone开发中动画效果实现分类代码是本文要介绍的内容,但是 ... -
UIView
2012-02-22 11:54 870iPhone开发应用之UIView开 ... -
iso随笔3
2012-02-13 15:11 087修改UIAlertView背景 UIAlertVie ... -
ios随笔2
2011-12-31 15:35 045 判断是否是 26 个英文 zimu ... -
Lvalue required as left operand of assignment error
2011-12-31 09:25 3350Hello I get the "Lvalue re ... -
ios随笔2
2011-12-27 14:21 045判断是否是26个英文zimu NSString* ... -
ios随笔2
2011-12-27 14:21 045判断是否是26个英文zimu NSString* ... -
tmp
2011-12-16 10:06 1274http://cache.baidu.com/c?m=9d78 ... -
todo
2011-12-12 13:30 0http://bbs.51cto.com/thread-845 ... -
iphone客户端解压gzip
2011-12-11 09:04 1654-(NSData *)uncompressZippedD ... -
HLS
2011-12-11 09:04 4380OS设备上要用原生的浏览器或者播放器来跑直播流媒体,确实是有点 ... -
Flash Media Server 4.5带来Flash末日?
2011-11-01 15:09 1436原文链接:Flash Media Se ... -
IOS开发之──应用之间调用(转)
2011-10-31 14:41 1789转自:http://blog.csdn.net/pjk1129 ... -
iPhone实战:操作SQLite(转)
2011-12-11 09:05 1886SQLite是一款轻量级的数据库,是遵守ACID的关联式数据库 ... -
内存管理
2011-12-11 09:05 848内存管理可以说是 iPhone 开发中最重要也最令人头疼的关键 ... -
连接 iPhone 的sqlite数据库的一段代码例子(转)
2011-10-26 10:39 1252原帖地址 http://www.cocoachina.com/ ... -
site
2011-10-21 17:52 951常用开发代码:http://www.cnblogs.com/K ... -
ios与android解析(转)
2011-10-17 10:45 912http://bbs.xiaomi.com/thread-34 ... -
电子杂志例子
2011-10-14 17:36 0----------- 程序结构说明及知识点 1。主体是n ...
相关推荐
这是iPhone之NSString常用方法示例程序,具体参考: http://blog.csdn.net/htttw/article/details/7884632
常用NSString字符串操作,主要有字符串截取 读取文件内容等等
iOS NSString详细操作,包含nsstring常用的操作说明。
(2)常用创建方法 代码如下: NSString *string = [[NSString alloc] init]; string = @”i am an iOSDevTip too!”; (3)用initWithString创建字符串 代码如下: NSString *string = [[NSString alloc] ...
自己闲着没事把常用的NSString处理封装了一个大牛类,包括常用的字符串处理,本地存储,小伙伴拿到后倒入工程,对于一些复杂的处理,一句话搞定
包含自定义键盘,一行代码搞定键盘覆盖问题,重写导航栏返回按钮事件,NSString常用封装
下面就来给大家详细介绍iOS中valueForKeyPath的常用方法,话不多说了,来一起看看详细的介绍吧 valueForKeyPath的常用方法 1、valueForKeyPath可以获取数组中的最小值、最大值、平均值、求和。代码如下: NSArray *...
1、整理UILabel、UIDevice、UIApplation、UIImage、UIImageView、UIView等UI...2、整理NSString、NSDictionary、NSData等常用数据结构的快捷定制方法 说明:使用方法同系统framework,支持IOS6以上的系统,不支持ARC
常用的方法,有下面几个: (NSString*)md5_base64: (NSString *) inPutText; (NSString*)encodeBase64String:(NSString *)input; (NSString*)decodeBase64String:(NSString *)input; (NSString*)encodeBase64...
ios开发常用的josn转NSString,转NSData,字典转json,非常方便使用
常用手机号,银行卡,身份证,邮箱等的判断
* CATransition 常用设置及属性注解如下: */ CATransition *animation = [CATransition animation]; /** delegate * * 动画的代理,如果你想在动画开始和结束的时候做一些事,可以设置此属性,它会自动回调两...
(void)showSuccess:(NSString *)success toView:(UIView *)view; /** 显示失败信息提示框 @param success 失败信息 @param view 指定显示信息的view */ (void)showError:(NSString *)error toView:(UIView *)view; /...
一、json、对象、字典等随意转换,容纳所有类型,包括常用的NSObject家族,基本数据类型int、long等,冷门的结构体、枚举等。 二、一行代码全自动转换。不管你的类中有数组、字典、其他对象类型还是基本类型,不管...
字符串 等 常用 代码方法
自己总结的对图像处理的一些常用功能封装成分类,可以款速设置圆形头像,只需一行代码: + (UIImage *)circleWithImage:(UIImage *)name borderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor;...
objective-c foundation框架,NSString,NSArray,等类的常用方法ppt
1. 数组的常用处理方式 //--------------------不可变数组 //1.数组的创建 NSString *s1 = @zhangsan; NSString *s2 = @lisi; NSString *s3 = @wangwu; //(1) NSArray *array1 = [[NSArray alloc] initWithObjects...
常用代码的封装。 ##如何使用 ### HDAlertViewManager(再也不用XXXAlertView) Objective-C + (void)alertWithMessage:(NSString *)message; + (void)alertWithTitle:(NSString *)title message:(NSString *)...