Add category function to access unsigned integer ivar

This commit is contained in:
Wenchao Ding 2016-11-10 06:59:02 +08:00
parent 5d02585467
commit aeb2c5464d
4 changed files with 21 additions and 2 deletions

View File

@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "FSCalendar"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "A superiorly awesome iOS7+ calendar control, compatible with Objective-C and Swift."
s.homepage = "https://github.com/WenchaoD/FSCalendar"

View File

@ -60,6 +60,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)fs_setVariable:(id)variable forKey:(NSString *)key;
- (id)fs_variableForKey:(NSString *)key;
- (void)fs_setUnsignedIntegerVariable:(NSUInteger)value forKey:(NSString *)key;
- (NSUInteger)fs_unsignedIntegerVariableForKey:(NSString *)key;
- (id)fs_performSelector:(SEL)selector withObjects:(nullable id)firstObject, ... NS_REQUIRES_NIL_TERMINATION;
@end

View File

@ -257,6 +257,21 @@
return variable;
}
- (void)fs_setUnsignedIntegerVariable:(NSUInteger)value forKey:(NSString *)key
{
Ivar ivar = class_getInstanceVariable([self class], key.UTF8String);
((void (*)(id, Ivar, NSUInteger))object_setIvar)(self, ivar, value);
}
- (NSUInteger)fs_unsignedIntegerVariableForKey:(NSString *)key
{
Ivar ivar = class_getInstanceVariable([self class], key.UTF8String);
ptrdiff_t offset = ivar_getOffset(ivar);
unsigned char *bytes = (unsigned char *)(__bridge void*)self;
NSUInteger value = *((NSUInteger *)(bytes+offset));
return value;
}
- (id)fs_performSelector:(SEL)selector withObjects:(nullable id)firstObject, ...
{
if (!selector) return nil;

View File

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.5.0</string>
<string>2.5.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>