Objective-C中对象API的基本应用
来源:互联网 发布:怎样增加淘宝店铺浏览量 编辑:程序博客网 时间:2024/06/05 06:13
//API-1 - (NSUInteger)length;
// 1 ***length消息为算字符的个数而不是所占
NSString * str = [NSStringstring];
NSString * str1 = [[NSStringalloc]init];
NSLog(@"*str1 count = %d",[str1retainCount]);//结果为-1
str =@"天行健";
str1 =@"IOS";
NSLog(@"str = %d,str1 = %d",[strlength],[str1length]);//length消息为算字符的个数而不是所占字节数,此结果均为3;
NSLog(@"str count = %d,str1 count = %d",[strretainCount],[str1retainCount]);//均为-1
[str1release];//注意内存管理问题;
// 2 ***
//API-2 - (unichar)characterAtIndex:(NSUInteger)index;//返回索引为index的字符(索引从0算起);
NSLog(@"%c",[str1characterAtIndex:0]);//对于字符串中是字母字符可以用%c来输出;
//NSString * str2 = [str characterAtIndex:1];//不可以用对象字符来接,注意其返回值;
char c = [strcharacterAtIndex:1];//这样并不能输出“天”字,“天”占两个字符!!
NSLog(@"%c",c);
// 3 ***
//- (void)getCharacters:(unichar *)buffer range:(NSRange)aRange;
NSString * str3 = [NSStringstringWithFormat:@"%@",@"IOS"];
NSMutableString * str31 = [NSMutableStringstringWithString:@"ios"];//对于可变字符串可以直接用普通字符串来初始化
NSString * str32 = [NSStringstringWithString:str3];//对于不可变字符串此方法仅能用对象来初始化
- Objective-C中对象API的基本应用
- Objective-C中基本数据烦类型与对象数据类型相互转换的方法(OC中NSString的常用API的基础应用3)
- Objective-C中数组对象排序的方法(OC中NSString的常用API的基础应用2)
- Objective-c中对象的归档
- objective-c中所谓的僵尸对象
- Objective-C中NSString对象的retainCount
- Objective-C中谓词(NSPredicate)的应用
- Objective-C中runtime机制的应用
- Objective-C中runtime机制的应用
- Objective-C中NSString和NSMutableString的基本用法
- Objective-C中NSArray和NSMutableArray的基本用法
- Objective-C中NSDictionary和NSMutableDictionary的基本用法
- Objective-C中NSArray和NSMutableArray的基本用法
- Objective-C中NSArray和NSMutableArray的基本用法
- 【转载】Objective-C中NSArray和NSMutableArray的基本用法
- Objective-C的基本语法
- Objective-C对象模型及应用
- Objective-C对象模型及应用
- 数据结构树--哈夫曼树
- Winform开发框架之系统登录实现
- HOJ 2267 Alice and Bob
- js 页面刷新location.reload和location.replace的区别小结
- spawn-fcgi工作原理
- Objective-C中对象API的基本应用
- 我的手机我做主 DIY个人手机应用平台
- js获得pdf文件的高度跟宽度
- JAVA程序员面试题
- 标签分页项目代码
- Memory Management Programming Guide for Core Foundation
- windows网络编程【003】实现简单WSASocket的C/S结构
- C++ 元编程 Meta Programming
- GameLoft面试题目