修复了部分UI,阿里推送token,wifi重名的问题

This commit is contained in:
wbzhan
2019-10-12 17:56:50 +08:00
parent 874c743f2b
commit d72f71f4df
32 changed files with 504 additions and 736 deletions
+69 -104
View File
@@ -27,35 +27,33 @@ static const char MJCachedPropertiesKey = '\0';
@implementation NSObject (Property)
static NSMutableDictionary *replacedKeyFromPropertyNameDict_;
static NSMutableDictionary *replacedKeyFromPropertyName121Dict_;
static NSMutableDictionary *newValueFromOldValueDict_;
static NSMutableDictionary *objectClassInArrayDict_;
static NSMutableDictionary *cachedPropertiesDict_;
+ (void)load
+ (NSMutableDictionary *)mj_propertyDictForKey:(const void *)key
{
replacedKeyFromPropertyNameDict_ = [NSMutableDictionary dictionary];
replacedKeyFromPropertyName121Dict_ = [NSMutableDictionary dictionary];
newValueFromOldValueDict_ = [NSMutableDictionary dictionary];
objectClassInArrayDict_ = [NSMutableDictionary dictionary];
cachedPropertiesDict_ = [NSMutableDictionary dictionary];
}
+ (NSMutableDictionary *)dictForKey:(const void *)key
{
@synchronized (self) {
if (key == &MJReplacedKeyFromPropertyNameKey) return replacedKeyFromPropertyNameDict_;
if (key == &MJReplacedKeyFromPropertyName121Key) return replacedKeyFromPropertyName121Dict_;
if (key == &MJNewValueFromOldValueKey) return newValueFromOldValueDict_;
if (key == &MJObjectClassInArrayKey) return objectClassInArrayDict_;
if (key == &MJCachedPropertiesKey) return cachedPropertiesDict_;
return nil;
}
static NSMutableDictionary *replacedKeyFromPropertyNameDict;
static NSMutableDictionary *replacedKeyFromPropertyName121Dict;
static NSMutableDictionary *newValueFromOldValueDict;
static NSMutableDictionary *objectClassInArrayDict;
static NSMutableDictionary *cachedPropertiesDict;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
replacedKeyFromPropertyNameDict = [NSMutableDictionary dictionary];
replacedKeyFromPropertyName121Dict = [NSMutableDictionary dictionary];
newValueFromOldValueDict = [NSMutableDictionary dictionary];
objectClassInArrayDict = [NSMutableDictionary dictionary];
cachedPropertiesDict = [NSMutableDictionary dictionary];
});
if (key == &MJReplacedKeyFromPropertyNameKey) return replacedKeyFromPropertyNameDict;
if (key == &MJReplacedKeyFromPropertyName121Key) return replacedKeyFromPropertyName121Dict;
if (key == &MJNewValueFromOldValueKey) return newValueFromOldValueDict;
if (key == &MJObjectClassInArrayKey) return objectClassInArrayDict;
if (key == &MJCachedPropertiesKey) return cachedPropertiesDict;
return nil;
}
#pragma mark - --私有方法--
+ (id)propertyKey:(NSString *)propertyName
+ (id)mj_propertyKey:(NSString *)propertyName
{
MJExtensionAssertParamNotNil2(propertyName, nil);
@@ -64,10 +62,6 @@ static NSMutableDictionary *cachedPropertiesDict_;
if ([self respondsToSelector:@selector(mj_replacedKeyFromPropertyName121:)]) {
key = [self mj_replacedKeyFromPropertyName121:propertyName];
}
// 兼容旧版本
if ([self respondsToSelector:@selector(replacedKeyFromPropertyName121:)]) {
key = [self performSelector:@selector(replacedKeyFromPropertyName121) withObject:propertyName];
}
// 调用block
if (!key) {
@@ -84,10 +78,6 @@ static NSMutableDictionary *cachedPropertiesDict_;
if ((!key || [key isEqual:propertyName]) && [self respondsToSelector:@selector(mj_replacedKeyFromPropertyName)]) {
key = [self mj_replacedKeyFromPropertyName][propertyName];
}
// 兼容旧版本
if ((!key || [key isEqual:propertyName]) && [self respondsToSelector:@selector(replacedKeyFromPropertyName)]) {
key = [self performSelector:@selector(replacedKeyFromPropertyName)][propertyName];
}
if (!key || [key isEqual:propertyName]) {
[self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
@@ -105,16 +95,12 @@ static NSMutableDictionary *cachedPropertiesDict_;
return key;
}
+ (Class)propertyObjectClassInArray:(NSString *)propertyName
+ (Class)mj_propertyObjectClassInArray:(NSString *)propertyName
{
__block id clazz = nil;
if ([self respondsToSelector:@selector(mj_objectClassInArray)]) {
clazz = [self mj_objectClassInArray][propertyName];
}
// 兼容旧版本
if ([self respondsToSelector:@selector(objectClassInArray)]) {
clazz = [self performSelector:@selector(objectClassInArray)][propertyName];
}
if (!clazz) {
[self mj_enumerateAllClasses:^(__unsafe_unretained Class c, BOOL *stop) {
@@ -137,8 +123,10 @@ static NSMutableDictionary *cachedPropertiesDict_;
+ (void)mj_enumerateProperties:(MJPropertiesEnumeration)enumeration
{
// 获得成员变量
NSArray *cachedProperties = [self properties];
MJExtensionSemaphoreCreate
MJExtensionSemaphoreWait
NSArray *cachedProperties = [self mj_properties];
MJExtensionSemaphoreSignal
// 遍历成员变量
BOOL stop = NO;
for (MJProperty *property in cachedProperties) {
@@ -148,34 +136,39 @@ static NSMutableDictionary *cachedPropertiesDict_;
}
#pragma mark - 公共方法
+ (NSMutableArray *)properties
+ (NSMutableArray *)mj_properties
{
NSMutableArray *cachedProperties = [self dictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)];
NSMutableArray *cachedProperties = [self mj_propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)];
if (cachedProperties == nil) {
cachedProperties = [NSMutableArray array];
[self mj_enumerateClasses:^(__unsafe_unretained Class c, BOOL *stop) {
// 1.获得所有的成员变量
unsigned int outCount = 0;
objc_property_t *properties = class_copyPropertyList(c, &outCount);
if (cachedProperties == nil) {
cachedProperties = [NSMutableArray array];
// 2.遍历每一个成员变量
for (unsigned int i = 0; i<outCount; i++) {
MJProperty *property = [MJProperty cachedPropertyWithProperty:properties[i]];
// 过滤掉Foundation框架类里面的属性
if ([MJFoundation isClassFromFoundation:property.srcClass]) continue;
property.srcClass = c;
[property setOriginKey:[self propertyKey:property.name] forClass:self];
[property setObjectClassInArray:[self propertyObjectClassInArray:property.name] forClass:self];
[cachedProperties addObject:property];
}
[self mj_enumerateClasses:^(__unsafe_unretained Class c, BOOL *stop) {
// 1.获得所有的成员变量
unsigned int outCount = 0;
objc_property_t *properties = class_copyPropertyList(c, &outCount);
// 2.遍历每一个成员变量
for (unsigned int i = 0; i<outCount; i++) {
MJProperty *property = [MJProperty cachedPropertyWithProperty:properties[i]];
// 过滤掉Foundation框架类里面的属性
if ([MJFoundation isClassFromFoundation:property.srcClass]) continue;
// 过滤掉`hash`, `superclass`, `description`, `debugDescription`
if ([MJFoundation isFromNSObjectProtocolProperty:property.name]) continue;
property.srcClass = c;
[property setOriginKey:[self mj_propertyKey:property.name] forClass:self];
[property setObjectClassInArray:[self mj_propertyObjectClassInArray:property.name] forClass:self];
[cachedProperties addObject:property];
}
// 3.释放内存
free(properties);
}];
// 3.释放内存
free(properties);
}];
[self dictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)] = cachedProperties;
[self mj_propertyDictForKey:&MJCachedPropertiesKey][NSStringFromClass(self)] = cachedProperties;
}
}
return cachedProperties;
@@ -192,10 +185,6 @@ static NSMutableDictionary *cachedPropertiesDict_;
if ([object respondsToSelector:@selector(mj_newValueFromOldValue:property:)]) {
return [object mj_newValueFromOldValue:oldValue property:property];
}
// 兼容旧版本
if ([self respondsToSelector:@selector(newValueFromOldValue:property:)]) {
return [self performSelector:@selector(newValueFromOldValue:property:) withObject:oldValue withObject:property];
}
// 查看静态设置
__block id newValue = oldValue;
@@ -214,7 +203,10 @@ static NSMutableDictionary *cachedPropertiesDict_;
{
[self mj_setupBlockReturnValue:objectClassInArray key:&MJObjectClassInArrayKey];
[[self dictForKey:&MJCachedPropertiesKey] removeAllObjects];
MJExtensionSemaphoreCreate
MJExtensionSemaphoreWait
[[self mj_propertyDictForKey:&MJCachedPropertiesKey] removeAllObjects];
MJExtensionSemaphoreSignal
}
#pragma mark - key配置
@@ -222,47 +214,20 @@ static NSMutableDictionary *cachedPropertiesDict_;
{
[self mj_setupBlockReturnValue:replacedKeyFromPropertyName key:&MJReplacedKeyFromPropertyNameKey];
[[self dictForKey:&MJCachedPropertiesKey] removeAllObjects];
MJExtensionSemaphoreCreate
MJExtensionSemaphoreWait
[[self mj_propertyDictForKey:&MJCachedPropertiesKey] removeAllObjects];
MJExtensionSemaphoreSignal
}
+ (void)mj_setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121
{
objc_setAssociatedObject(self, &MJReplacedKeyFromPropertyName121Key, replacedKeyFromPropertyName121, OBJC_ASSOCIATION_COPY_NONATOMIC);
[[self dictForKey:&MJCachedPropertiesKey] removeAllObjects];
MJExtensionSemaphoreCreate
MJExtensionSemaphoreWait
[[self mj_propertyDictForKey:&MJCachedPropertiesKey] removeAllObjects];
MJExtensionSemaphoreSignal
}
@end
@implementation NSObject (MJPropertyDeprecated_v_2_5_16)
+ (void)enumerateProperties:(MJPropertiesEnumeration)enumeration
{
[self mj_enumerateProperties:enumeration];
}
+ (void)setupNewValueFromOldValue:(MJNewValueFromOldValue)newValueFormOldValue
{
[self mj_setupNewValueFromOldValue:newValueFormOldValue];
}
+ (id)getNewValueFromObject:(__unsafe_unretained id)object oldValue:(__unsafe_unretained id)oldValue property:(__unsafe_unretained MJProperty *)property
{
return [self mj_getNewValueFromObject:object oldValue:oldValue property:property];
}
+ (void)setupReplacedKeyFromPropertyName:(MJReplacedKeyFromPropertyName)replacedKeyFromPropertyName
{
[self mj_setupReplacedKeyFromPropertyName:replacedKeyFromPropertyName];
}
+ (void)setupReplacedKeyFromPropertyName121:(MJReplacedKeyFromPropertyName121)replacedKeyFromPropertyName121
{
[self mj_setupReplacedKeyFromPropertyName121:replacedKeyFromPropertyName121];
}
+ (void)setupObjectClassInArray:(MJObjectClassInArray)objectClassInArray
{
[self mj_setupObjectClassInArray:objectClassInArray];
}
@end
#pragma clang diagnostic pop