NSValue.h
2016-09-04 本文已影响65人
ShenYj
/* NSValue.h
Copyright (c) 1994-2013, Apple Inc. All rights reserved.
*/
#import <Foundation/NSObject.h>
@class NSString, NSDictionary;
@interface NSValue : NSObject <NSCopying, NSSecureCoding>
- (void)getValue:(void *)value; // 将NSValue对象的值写入到 value(新的变量) 中,按照正确的类型来,可以取出任何类型
- (const char *)objCType NS_RETURNS_INNER_POINTER;
@end
@interface NSValue (NSValueCreation)
- (id)initWithBytes:(const void *)value objCType:(const char *)type;
// 将任意的结构体变量包装成OC对象
+ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type;
+ (NSValue *)value:(const void *)value withObjCType:(const char *)type;
@end
@interface NSValue (NSValueExtensionMethods)
+ (NSValue *)valueWithNonretainedObject:(id)anObject;
- (id)nonretainedObjectValue;
+ (NSValue *)valueWithPointer:(const void *)pointer;
- (void *)pointerValue;
- (BOOL)isEqualToValue:(NSValue *)value;
@end
@interface NSNumber : NSValue
- (char)charValue; // 将char类型包装成对象
- (unsigned char)unsignedCharValue; // 将unsigned char类型包装成对象
- (short)shortValue; // 将short类型包装成对象
- (unsigned short)unsignedShortValue; // 将unsigned short类型包装成对象
- (int)intValue; //
- (unsigned int)unsignedIntValue;
- (long)longValue;
- (unsigned long)unsignedLongValue;
- (long long)longLongValue;
- (unsigned long long)unsignedLongLongValue;
- (float)floatValue;
- (double)doubleValue;
- (BOOL)boolValue;
- (NSInteger)integerValue NS_AVAILABLE(10_5, 2_0);
- (NSUInteger)unsignedIntegerValue NS_AVAILABLE(10_5, 2_0);
- (NSString *)stringValue;
- (NSComparisonResult)compare:(NSNumber *)otherNumber;
- (BOOL)isEqualToNumber:(NSNumber *)number;
- (NSString *)descriptionWithLocale:(id)locale;
@end
@interface NSNumber (NSNumberCreation)
- (id)initWithChar:(char)value;
- (id)initWithUnsignedChar:(unsigned char)value;
- (id)initWithShort:(short)value;
- (id)initWithUnsignedShort:(unsigned short)value;
- (id)initWithInt:(int)value;
- (id)initWithUnsignedInt:(unsigned int)value;
- (id)initWithLong:(long)value;
- (id)initWithUnsignedLong:(unsigned long)value;
- (id)initWithLongLong:(long long)value;
- (id)initWithUnsignedLongLong:(unsigned long long)value;
- (id)initWithFloat:(float)value;
- (id)initWithDouble:(double)value;
- (id)initWithBool:(BOOL)value;
- (id)initWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0);
- (id)initWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0);
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
+ (NSNumber *)numberWithInt:(int)value;
+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
+ (NSNumber *)numberWithLong:(long)value;
+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
+ (NSNumber *)numberWithLongLong:(long long)value;
+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
+ (NSNumber *)numberWithFloat:(float)value;
+ (NSNumber *)numberWithDouble:(double)value;
+ (NSNumber *)numberWithBool:(BOOL)value;
+ (NSNumber *)numberWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0);
+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0);
@end