[英]how can I retrieve an integer value from an NSMutableArray on the iPhone?
如何从NSMutableArray中获取整数值?
You have this extends if you want 如果你愿意,你有这个扩展
Create file extends.h add this code and #import "extends.h" in your project : 创建文件extends.h在项目中添加此代码和#import“extends.h” :
/*______________________________ Extends NSMutableArray ______________________________*/
/**
* Extend NSMutableArray
* By DaRkD0G
*/
@interface NSMutableArray (NSArrayAdd)
/**
* Get element at index
*
* @param index
*/
- (NSObject *) getAt:(int) index;
@end
/**
* Extend NSMutableArray Method
* By DaRkD0G
*/
@implementation NSMutableArray (NSArrayAdd)
/**
* Get element at index
*
* @param index
*/
- (NSObject *) getAt:(int) index {
NSInteger anIndex = index;
NSObject *object = [self objectAtIndex:anIndex];
if (object == [NSNull null]) {
return nil;
} else {
NSLog(@"OK found ");
return object;
}
}
@end
/*______________________________ Extends NSArray ______________________________*/
/**
* Extend NSArray
* By DaRkD0G
*/
@interface NSArray (NSArrayAdd)
/**
* Get element at index
*
* @param index
*/
- (NSObject *) getAt:(int) index;
@end
/**
* Extend NSArray Method
* By DaRkD0G
*/
@implementation NSArray (NSArrayAdd)
/**
* Get element at index
*
* @param index
*/
- (NSObject *) getAt:(int) index {
NSInteger anIndex = index;
NSObject *object = [self objectAtIndex:anIndex];
if (object == [NSNull null]) {
return nil;
} else {
NSLog(@"OK found ");
return object;
}
}
@end
USE : 采用 :
NSObject object = [self.arrayItem getAt:0];
NSObject object2 = [self.arrayItem getAt:50];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.