想知道无论如何我们可以解决在 Mantle 中将带空格的字符串转换为 NSURL 失败的问题吗?
我正在低于 Mantle 错误:
错误域=MTLTransformerErrorHandlingErrorDomain Code=1“无法将字符串转换为 URL”UserInfo=0x7ff9e8de4090 {MTLTransformerErrorHandlingInputValueErrorKey= https://x.com/dev-pub-image-md/x-img/02020-x yy z@2X.png , NSLocalizedDescription=无法将字符串转换为 URL,NSLocalizedFailureReason=输入 URL 字符串https://x.com/dev-pub-image-md/x-img/02020-x yy z@2X.png 格式错误}
在类文件下方;
。H -
#import "Mantle.h"
@interface Place : MTLModel <MTLJSONSerializing>
@property (strong, nonatomic) NSString *placeId;
@property (strong, nonatomic) NSURL *logoURL;
@end
.m -
#import "Place.h"
@implementation Place
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{@"placeId": @"placeId",
@"logoURL":@"circleImage"
};
}
+ (NSValueTransformer *)logoURLJSONTransformer {
return [NSValueTransformer valueTransformerForName:MTLURLValueTransformerName];
}
@end
提前致谢!