Skip to content

Commit c39d602

Browse files
author
erichmzhang
committed
# 5.4.2
- 修复了返回数组类型的属性,如果数组内容只有一个时候会解析失败的问题。
1 parent 0ee75b0 commit c39d602

26 files changed

+179
-181
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 5.4.2
2+
- 修复了返回数组类型的属性,如果数组内容只有一个时候会解析失败的问题。
3+
14
# 5.4.1
25
- 修复了 XML 中以 / 结尾的 Object 会403的的问题。
36

QCloudCOSXML.podspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "QCloudCOSXML"
3-
s.version = "5.4.1"
3+
s.version = "5.4.2"
44
s.summary = "QCloudCOSXML 腾讯云iOS-SDK组件"
55

66
s.homepage = "https://cloud.tencent.com/"
@@ -9,10 +9,10 @@ s.version = "5.4.1"
99
s.source = { :git => "https://github.com/tencentyun/qcloud-sdk-ios.git", :tag => s.version.to_s }
1010
s.ios.deployment_target = '8.0'
1111
s.source_files = 'QCloudCOSXML/Classes/**/*'
12-
s.dependency "QCloudCore",'5.4.1'
12+
s.dependency "QCloudCore",'5.4.2'
1313

1414
s.subspec 'Transfer' do |sbt|
1515
sbt.source_files = 'QCloudCOSXML/Classes/Transfer/*','QCloudCOSXML/Classes/Base/*'
16-
sbt.dependency "QCloudCore",'5.4.1'
16+
sbt.dependency "QCloudCore",'5.4.2'
1717
end
1818
end

QCloudCOSXML/Classes/Base/QCloudCOSXMLEndPoint.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,11 @@ - (NSURL*) serverURLWithBucket:(NSString *)bucket appID:(NSString *)appID
6161
NSURL* serverURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@-%@.%@.%@",scheme,formattedBucketName,appID,formattedRegionName,self.serviceName]];
6262
return serverURL;
6363
}
64+
65+
- (id)copyWithZone:(NSZone *)zone {
66+
QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] init];
67+
endpoint.regionName = self.regionName;
68+
endpoint.serviceName = self.serviceName;
69+
return endpoint;
70+
}
6471
@end

QCloudCOSXML/Classes/Base/QCloudCOSXMLService.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838
#pragma Factory
3939
+ (QCloudCOSXMLService*) defaultCOSXML;
4040
+ (QCloudCOSXMLService*) cosxmlServiceForKey:(NSString*)key;
41+
42+
/**
43+
检查是否存在key对应的service
44+
45+
@param key key
46+
@return 存在与否
47+
48+
*/
49+
+ (BOOL) hasServiceForKey:(NSString*)key;
4150
+ (QCloudCOSXMLService*) registerDefaultCOSXMLWithConfiguration:(QCloudServiceConfiguration*)configuration;
4251
+ (QCloudCOSXMLService*) registerCOSXMLWithConfiguration:(QCloudServiceConfiguration*)configuration withKey:(NSString*)key;
4352
+ (void) removeCOSXMLWithKey:(NSString*)key;

QCloudCOSXML/Classes/Base/QCloudCOSXMLService.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,13 @@ - (NSString*)getURLWithBucket:(NSString *)bucket object:(NSString *)object withA
104104
return [resultURL copy];
105105
}
106106

107+
+ (BOOL)hasServiceForKey:(NSString *)key {
108+
if (nil == [QCloudCOSXMLServiceCache() objectForKey:key]) {
109+
return NO;
110+
} else {
111+
return YES;
112+
}
113+
}
114+
107115

108116
@end

QCloudCOSXML/Classes/Manager/QCloudACLPolicy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#import <Foundation/Foundation.h>
2929
#import <QCloudCore/QCloudCore.h>
3030
#import "QCloudACLOwner.h"
31-
#import "QCloudACLGrant.h"
31+
#import "QCloudAccessControlList.h"
3232

3333
NS_ASSUME_NONNULL_BEGIN
3434
@interface QCloudACLPolicy : NSObject
@@ -39,6 +39,6 @@ NS_ASSUME_NONNULL_BEGIN
3939
/**
4040
被授权者与权限的信息
4141
*/
42-
@property (strong, nonatomic) NSArray<QCloudACLGrant*> *accessControlList;
42+
@property (strong, nonatomic) QCloudAccessControlList *accessControlList;
4343
@end
4444
NS_ASSUME_NONNULL_END

QCloudCOSXML/Classes/Manager/QCloudACLPolicy.m

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,12 @@
2727
#import "QCloudACLPolicy.h"
2828

2929
#import "QCloudACLOwner.h"
30-
#import "QCloudACLGrant.h"
30+
#import "QCloudAccessControlList.h"
3131

32-
@class QCloudACLGrant;
3332

3433
NS_ASSUME_NONNULL_BEGIN
3534
@implementation QCloudACLPolicy
3635

37-
+ (NSDictionary *)modelContainerPropertyGenericClass
38-
{
39-
return @ {
40-
@"accessControlList":[QCloudACLGrant class],
41-
};
42-
}
4336

4437

4538
+ (NSDictionary *)modelCustomPropertyMapper
@@ -53,22 +46,6 @@ + (NSDictionary *)modelCustomPropertyMapper
5346

5447
- (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic
5548
{
56-
void(^TransformDictionary)(NSString* originKey, NSString* aimKey) = ^(NSString* originKey, NSString* aimKey) {
57-
id object = [dic objectForKey:originKey];
58-
if (!object) {
59-
return;
60-
}
61-
if ([object isKindOfClass:[NSNull class]]) {
62-
return;
63-
}
64-
if ([object isKindOfClass:[NSArray class]]) {
65-
NSArray* objects = (NSArray*)object;
66-
[dic removeObjectForKey:originKey];
67-
NSMutableDictionary* transferDic = [@{aimKey:objects} mutableCopy];
68-
[dic setObject:transferDic forKey:originKey];
69-
}
70-
};
71-
TransformDictionary(@"AccessControlList", @"Grant");
7249

7350

7451
return YES;
@@ -80,31 +57,6 @@ - (NSDictionary *)modelCustomWillTransformFromDictionary:(NSDictionary *)dic
8057
return dic;
8158
}
8259
NSMutableDictionary* transfromDic = [NSMutableDictionary dictionaryWithDictionary:dic];
83-
NSArray* transformArrayKeypaths = @[
84-
@"AccessControlList",
85-
];
86-
87-
for (NSString* keyPath in transformArrayKeypaths) {
88-
id object = [dic valueForKeyPath:keyPath];
89-
if (!object) {
90-
continue;
91-
}
92-
if ([object isKindOfClass:[NSNull class]]) {
93-
continue;
94-
}
95-
if (![object isKindOfClass:[NSArray class]]) {
96-
if ([object isKindOfClass:[NSDictionary class]] && [(NSDictionary*)object count] == 1) {
97-
id value = [[object allValues] firstObject];
98-
if ([value isKindOfClass:[NSArray class]]) {
99-
[transfromDic setValue:value forKey:keyPath];
100-
} else {
101-
[transfromDic setValue:@[value] forKey:keyPath];
102-
}
103-
} else {
104-
[transfromDic setValue:@[object] forKeyPath:keyPath];
105-
}
106-
}
107-
}
10860

10961
return transfromDic;
11062
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// QCloudAccessControlList.h
3+
// QCloudAccessControlList
4+
//
5+
// Created by tencent
6+
// Copyright (c) 2015年 tencent. All rights reserved.
7+
//
8+
// ██████╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ████████╗███████╗██████╗ ███╗ ███╗██╗███╗ ██╗ █████╗ ██╗ ██╗ █████╗ ██████╗
9+
// ██╔═══██╗██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗ ╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗██║ ██║ ██╔══██╗██╔══██╗
10+
// ██║ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ █████╗ ██████╔╝██╔████╔██║██║██╔██╗ ██║███████║██║ ██║ ███████║██████╔╝
11+
// ██║▄▄ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ ██╔══╝ ██╔══██╗██║╚██╔╝██║██║██║╚██╗██║██╔══██║██║ ██║ ██╔══██║██╔══██╗
12+
// ╚██████╔╝╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║███████╗ ███████╗██║ ██║██████╔╝
13+
// ╚══▀▀═╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═════╝
14+
//
15+
//
16+
// _ __ _ _
17+
// (_) / _| | | | |
18+
// ___ ___ _ ____ ___ ___ ___ | |_ ___ _ __ __| | _____ _____| | ___ _ __ ___ _ __ ___
19+
// / __|/ _ \ '__\ \ / / |/ __/ _ \ | _/ _ \| '__| / _` |/ _ \ \ / / _ \ |/ _ \| '_ \ / _ \ '__/ __|
20+
// \__ \ __/ | \ V /| | (_| __/ | || (_) | | | (_| | __/\ V / __/ | (_) | |_) | __/ | \__
21+
// |___/\___|_| \_/ |_|\___\___| |_| \___/|_| \__,_|\___| \_/ \___|_|\___/| .__/ \___|_| |___/
22+
// ______ ______ ______ ______ ______ ______ ______ ______ | |
23+
// |______|______|______|______|______|______|______|______| |_|
24+
//
25+
26+
27+
28+
#import <Foundation/Foundation.h>
29+
#import <QCloudCore/QCloudCore.h>
30+
#import "QCloudACLGrant.h"
31+
32+
NS_ASSUME_NONNULL_BEGIN
33+
@interface QCloudAccessControlList : NSObject
34+
/**
35+
存放被授权者信息的数组
36+
*/
37+
@property (strong, nonatomic) NSArray<QCloudACLGrant*> *ACLGrants;
38+
@end
39+
NS_ASSUME_NONNULL_END
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// QCloudAccessControlList.m
3+
// QCloudAccessControlList
4+
//
5+
// Created by tencent
6+
// Copyright (c) 2015年 tencent. All rights reserved.
7+
//
8+
// ██████╗ ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ████████╗███████╗██████╗ ███╗ ███╗██╗███╗ ██╗ █████╗ ██╗ ██╗ █████╗ ██████╗
9+
// ██╔═══██╗██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗ ╚══██╔══╝██╔════╝██╔══██╗████╗ ████║██║████╗ ██║██╔══██╗██║ ██║ ██╔══██╗██╔══██╗
10+
// ██║ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ █████╗ ██████╔╝██╔████╔██║██║██╔██╗ ██║███████║██║ ██║ ███████║██████╔╝
11+
// ██║▄▄ ██║██║ ██║ ██║ ██║██║ ██║██║ ██║ ██║ ██╔══╝ ██╔══██╗██║╚██╔╝██║██║██║╚██╗██║██╔══██║██║ ██║ ██╔══██║██╔══██╗
12+
// ╚██████╔╝╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██║██║ ╚████║██║ ██║███████╗ ███████╗██║ ██║██████╔╝
13+
// ╚══▀▀═╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═════╝
14+
//
15+
//
16+
// _ __ _ _
17+
// (_) / _| | | | |
18+
// ___ ___ _ ____ ___ ___ ___ | |_ ___ _ __ __| | _____ _____| | ___ _ __ ___ _ __ ___
19+
// / __|/ _ \ '__\ \ / / |/ __/ _ \ | _/ _ \| '__| / _` |/ _ \ \ / / _ \ |/ _ \| '_ \ / _ \ '__/ __|
20+
// \__ \ __/ | \ V /| | (_| __/ | || (_) | | | (_| | __/\ V / __/ | (_) | |_) | __/ | \__
21+
// |___/\___|_| \_/ |_|\___\___| |_| \___/|_| \__,_|\___| \_/ \___|_|\___/| .__/ \___|_| |___/
22+
// ______ ______ ______ ______ ______ ______ ______ ______ | |
23+
// |______|______|______|______|______|______|______|______| |_|
24+
//
25+
26+
27+
#import "QCloudAccessControlList.h"
28+
29+
#import "QCloudACLGrant.h"
30+
31+
@class QCloudACLGrant;
32+
33+
NS_ASSUME_NONNULL_BEGIN
34+
@implementation QCloudAccessControlList
35+
36+
+ (NSDictionary *)modelContainerPropertyGenericClass
37+
{
38+
return @ {
39+
@"ACLGrants":[QCloudACLGrant class],
40+
};
41+
}
42+
43+
44+
+ (NSDictionary *)modelCustomPropertyMapper
45+
{
46+
return @{
47+
@"ACLGrants" :@"Grant",
48+
};
49+
}
50+
51+
52+
- (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic
53+
{
54+
55+
56+
return YES;
57+
}
58+
59+
- (NSDictionary *)modelCustomWillTransformFromDictionary:(NSDictionary *)dic
60+
{
61+
if (!dic) {
62+
return dic;
63+
}
64+
NSMutableDictionary* transfromDic = [NSMutableDictionary dictionaryWithDictionary:dic];
65+
NSArray* transformArrayKeypaths = @[
66+
@"Grant",
67+
];
68+
69+
for (NSString* keyPath in transformArrayKeypaths) {
70+
id object = [dic valueForKeyPath:keyPath];
71+
if (!object) {
72+
continue;
73+
}
74+
if ([object isKindOfClass:[NSNull class]]) {
75+
continue;
76+
}
77+
if (![object isKindOfClass:[NSArray class]]) {
78+
[transfromDic setValue:@[object] forKeyPath:keyPath];
79+
}
80+
}
81+
82+
return transfromDic;
83+
}
84+
85+
@end
86+
87+
88+
NS_ASSUME_NONNULL_END

QCloudCOSXML/Classes/Manager/QCloudBucketReplicationConfiguation.m

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,7 @@ - (NSDictionary *)modelCustomWillTransformFromDictionary:(NSDictionary *)dic
7676
continue;
7777
}
7878
if (![object isKindOfClass:[NSArray class]]) {
79-
if ([object isKindOfClass:[NSDictionary class]] && [(NSDictionary*)object count] == 1) {
80-
id value = [[object allValues] firstObject];
81-
if ([value isKindOfClass:[NSArray class]]) {
82-
[transfromDic setValue:value forKey:keyPath];
83-
} else {
84-
[transfromDic setValue:@[value] forKey:keyPath];
85-
}
86-
} else {
87-
[transfromDic setValue:@[object] forKeyPath:keyPath];
88-
}
79+
[transfromDic setValue:@[object] forKeyPath:keyPath];
8980
}
9081
}
9182

0 commit comments

Comments
 (0)