objective-c之复合对象
来源:互联网 发布:矩阵的qr分解例题 编辑:程序博客网 时间:2024/04/28 06:14
#import <Foundation/Foundation.h>//自定义验证表数组ValidatingArray@interface ValidatingArray : NSMutableArray{ NSMutableArray *embeddedArray;}+ validatingArray;- init;- (unsigned)count;- objectAtIndex:(unsigned)index;- (void)addObject:object;- (void)replaceObjectAtIndex:(unsigned)index withObject:object;- (void)removeLastObject;- (void)insertObject:object atIndex:(unsigned)index;- (void)removeObjectAtIndex:(unsigned)index;@end@implementation ValidatingArray- init{ self = [super init]; if (self) { embeddedArray = [[NSMutableArray allocWithZone:[self zone]] init]; } return self;}+ validatingArray{ return [[self alloc] init] ;}- (unsigned)count{ return [embeddedArray count];}- objectAtIndex:(unsigned)index{ return [embeddedArray objectAtIndex:index];}- (void)addObject:(id)object{ if (object != nil) { [embeddedArray addObject:object]; }}- (void)replaceObjectAtIndex:(unsigned)index withObject:(id)object;{ if (index <[embeddedArray count] && object != nil) { [embeddedArray replaceObjectAtIndex:index withObject:object]; }}- (void)removeLastObject;{ if ([embeddedArray count] > 0) { [embeddedArray removeLastObject]; }}- (void)insertObject:(id)object atIndex:(unsigned)index;{ if (object != nil) { [embeddedArray insertObject:object atIndex:index]; }}- (void)removeObjectAtIndex:(unsigned)index;{ if (index <[embeddedArray count]) { [embeddedArray removeObjectAtIndex:index]; }}@end//http://www.yiibai.com/objective_c/objective_c_composite_objects.htmlint main(){ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; ValidatingArray *validatingArray = [ValidatingArray validatingArray]; [validatingArray addObject:@"Object1"]; [validatingArray addObject:@"Object2"]; [validatingArray addObject:[NSNull null]]; [validatingArray removeObjectAtIndex:2]; NSString *aString = [validatingArray objectAtIndex:1]; NSLog(@"The value at Index 1 is %@",aString); aString = [validatingArray objectAtIndex:0]; NSLog(@"The value at Index 0 is %@",aString); [pool drain]; return 0;}
0 0
- objective-c之复合对象
- IOS开发之路-Objective-C 复合
- 【iOS开发之Objective-C】复合
- objective-c 复合
- Objective-C之数组对象
- Objective-C,复合类,Composition
- Objective-c语言_复合
- Objective-C 类的复合
- 【OC复合题】之定义一个学生类,需要有姓名,年龄,考试成绩三个成员属性,创建5个对象,属性可以任意值。(Objective-C)
- 我的iOS开发之Objective-C第4天之属性、复合
- Objective-C语法之词典对象
- Objective-C语法之集合对象
- iPhone开发之Objective-C类对象
- Objective-C 语法之集合对象
- Objective-C 语法之集合对象
- 1.类与对象之objective-c
- Objective-C 语法之集合对象
- 1.类与对象之objective-c
- 51nod:1010 只包含因子2 3 5的数
- Android图片异步上传到PHP服务器实例
- 大型网站技术架构:核心原理与案例分析—第七章:随需应变:网站的可扩展架构
- View的绘制流程(需要进一步加深)
- c#键盘事件代码keychar
- objective-c之复合对象
- 如果看了此文你还不懂傅里叶变换,那就过来掐死我吧【完整版】
- HDU 5602 Black Jack(概率DP)
- logstash input output filter 插件总结
- ubuntu12.04+hadoop2.2.0+zookeeper3.4.5+hbase0.96.2+hive0.13.1伪分布式环境部署
- window.history.go(-1)和window.location.go(-1)的区别
- oj:写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写
- IOS中对图片的处理 UIImage
- ScrollView根布局和systembartint冲突