/--------枚举---------
//C 的枚举 :列举,集合,常数;
enum jack {
age = 10
};
// typedef 定义类目的别名
// 枚举里不可以重复定义
typedef enum{
hehe = 10
} jackI;
NSEnumerator *enumer1 = [dict2 objectEnumerator];
id thingie1;
while( (thingie1)= [enumer1 nextObject]) {
NSLog("字典枚举出来的结果>>%
",thingie1);
}
//结构体 NSRect
NSRect rect = NSMakeRect(21.3, 31.1, 1.12, 312.3) ;
NSLog("%.2f %.2f %.2f %.2f",rect.origin.x,rect.origin.y,rect.size.height,rect.size.width);
"Imperial India Pale Ale (IPA)";
//NSRange
NSString *homebrew =
NSRange range = NSMakeRange(25, 3);
NSLog("输出IPA:%
",[homebrew substringWithRange:range]);
//搜索字符串:
NSRange rangeI = [homebrew rangeOfString:"IPA"];
"Range is:%@",NSStringFromRange(rangeI));
if (rangeI.length >0) {
NSLog(
}
//NSPoint
NSPoint point;
// 结构体里面的点进行赋值
point.x = 10;
point.y = 10;
point = NSMakePoint(10, 18);//快速创点
//常见的CGPointMake创点的函数
point = CGPointMake(29, 78);
NSString *pointI = NSStringFromPoint(point);
NSLog("point is%
",pointI);
//NSSize尺寸
NSSize size ;
size.width = 100;
size.height = 22;
// size = NSMakeSize(12, 21);
// size = CGSizeMake(11, 11);
NSString *sizeI = NSStringFromSize(size);
NSLog("%
",sizeI);
//--------NSDate---------
//--------NSDate转换为NSString---------
NSDate *date = [[NSDate alloc]init];
NSDateFormatter *date1 =[[NSDateFormatter alloc]init];
[date1 setDateFormat:"yy年MM月dd日 HH:mm:ss"];//大写HH为24小时制,小写hh为12小时制
"%
NSString *now = [date1 stringFromDate:date];
NSLog(",now);
"2015年10月15日 5:51:25";
//--------NSString转换为NSDate---------
NSString *stringTime =
NSDate *dateNew = [[NSDate alloc]init];
dateNew = [date1 dateFromString:stringTime];
NSLog("=====>%
",dateNew);
//NSValue是NSNumber的父类;
//声明并初始化一个struct
NSRect rtc = NSMakeRect(12, 32, 433, 132);
//创建一个NSValue:
//value:对象地址
//objCType:通常是一个用来描述对象类型和大小的字符串,@encode会自动生成一个合适的描述字符串
NSValue *value = [NSValue valueWithBytes:&rtc objCType:@encode(NSRect)];
//把Value添加到数组中
NSMutableArray *array1 = [NSMutableArray arrayWithCapacity:10];
[array1 addObject:value];
NSRect rt;
//从数组中取到NSValue,因为只添加了一个,所以小标是0
NSValue *v = [array1 objectAtIndex:0];
//从value中取得一个NSSet,虽然返回值是void,但其实是它利用指针返回值的
[v getValue:&rt];
//输出结果
NSLog("%.2f %.2f %.2f %.2f ",rt.origin.x,rt.origin.y,rt.size.height,rt.size.width);
"%.2f %.2f %.2f %.2f ",rt.origin.x,rt.origin.y,rt.size.height,rt.size.width);
//用快速枚举遍历array并输出NSValue中struct属性的值
for (NSValue *v in array1) {
NSRect rt;
[v getValue:&rt];
NSLog(
}
//--------便捷的struct转换成NSValue方式---------
//声明并初始化一个struct
NSRect rtc1 = NSMakeRect(100, 200, 300, 400);
//创建一个NSValue
NSValue *value1 = [NSValue valueWithRect:rtc1];
//把value1添加到数组中
NSMutableArray *array3 = [NSMutableArray arrayWithCapacity:10];
[array3 addObject:value];
NSRect rt1 = [value1 rectValue];
//输出
NSLog(@"%.1f %.1f %.1f %.1f",rt1.origin.x,rt1.origin.y, rt1.size.height, rt1.size.width);
//--------id新手只需知道它可以代表所有---------
Person *personhe = [[Person alloc]init];
Man *manhe = [[Man alloc]init];
Man *mands = [[Person alloc]init];
id presonde = [[Person alloc]init];
id mande = [[Man alloc]init];
id string11 = [[NSString alloc]init];
id object11 = [[NSObject alloc]init];