Commit be69cb93 authored by 曹云霄's avatar 曹云霄

修复订单支付完成加载框不消失bug,适配IOS10

parent 98877ecf
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="10117" systemVersion="16A323" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies> </dependencies>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="是否开票:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="444-pT-XHf"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="是否开票:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="444-pT-XHf">
<rect key="frame" x="21" y="13" width="70" height="17"/> <rect key="frame" x="21" y="13" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="发票抬头:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="MoA-e8-03W"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="发票抬头:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="MoA-e8-03W">
<rect key="frame" x="21" y="45" width="70" height="17"/> <rect key="frame" x="21" y="45" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="发票类型:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Zdn-MM-Xad"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="发票类型:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Zdn-MM-Xad">
<rect key="frame" x="367" y="13" width="70" height="17"/> <rect key="frame" x="367" y="13" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="支付方式:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="S5V-nq-hin"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="支付方式:" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="S5V-nq-hin">
<rect key="frame" x="367" y="43" width="70" height="17"/> <rect key="frame" x="367" y="43" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
......
...@@ -92,28 +92,29 @@ ...@@ -92,28 +92,29 @@
- (void)getOrderDetailsData - (void)getOrderDetailsData
{ {
[self CreateMBProgressHUDLoding]; [self CreateMBProgressHUDLoding];
WS(weakSelf);
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(ORDERDETAILS),self.orderCode] WithRequestType:1 WithParameter:nil WithReturnValueBlock:^(id returnValue) { [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:[NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(ORDERDETAILS),self.orderCode] WithRequestType:1 WithParameter:nil WithReturnValueBlock:^(id returnValue) {
[self RemoveMBProgressHUDLoding]; [weakSelf RemoveMBProgressHUDLoding];
if ([returnValue[@"code"] isEqualToNumber:@0]) { if ([returnValue[@"code"] isEqualToNumber:@0]) {
self.orderDetails = [[OrderBill alloc]initWithDictionary:returnValue[@"data"] error:nil]; weakSelf.orderDetails = [[OrderBill alloc]initWithDictionary:returnValue[@"data"] error:nil];
[self.orderDetailsTableview reloadData]; [weakSelf.orderDetailsTableview reloadData];
//默认弹出支付框 //默认弹出支付框
if (self.isShowPayButton && [self.orderDetails.order.orderState isEqualToString:@"001"]) { if (weakSelf.isShowPayButton && [weakSelf.orderDetails.order.orderState isEqualToString:@"001"]) {
[self PayButtonClick]; [weakSelf PayButtonClick];
} }
} }
else else
{ {
[self ErrorMBProgressView:returnValue[@"message"]]; [weakSelf ErrorMBProgressView:returnValue[@"message"]];
} }
} WithErrorCodeBlock:^(id errorCodeValue) { } WithErrorCodeBlock:^(id errorCodeValue) {
[weakSelf RemoveMBProgressHUDLoding];
} WithFailureBlock:^(id error) { [weakSelf ErrorMBProgressView:NETWORK];
} WithFailureBlock:^(NSError *error) {
[self RemoveMBProgressHUDLoding]; [weakSelf RemoveMBProgressHUDLoding];
[weakSelf ErrorMBProgressView:error.localizedDescription];
}]; }];
} }
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="10117" systemVersion="16A323" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
<dependencies> <dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies> </dependencies>
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="吊牌价:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ol6-U8-o5v"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="吊牌价:" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ol6-U8-o5v">
<rect key="frame" x="530" y="152" width="56" height="17"/> <rect key="frame" x="530" y="152" width="60" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/> <fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
......
...@@ -87,12 +87,10 @@ ...@@ -87,12 +87,10 @@
#pragma mark -获取商品详情 #pragma mark -获取商品详情
- (void)getGoodsListDetails - (void)getGoodsListDetails
{ {
[self CreateMBProgressHUDLoding]; [self CreateMBProgressHUDLoding];
NSString *url = [NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(GOODSDETAILS),_goodsID]; NSString *url = [NSString stringWithFormat:@"%@%@",SERVERREQUESTURL(GOODSDETAILS),_goodsID];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:url WithRequestType:1 WithParameter:nil WithReturnValueBlock:^(id returnValue) { [[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:url WithRequestType:1 WithParameter:nil WithReturnValueBlock:^(id returnValue) {
[self RemoveMBProgressHUDLoding]; [self RemoveMBProgressHUDLoding];
if ([returnValue[@"code"] isEqualToNumber:@0]) { if ([returnValue[@"code"] isEqualToNumber:@0]) {
...@@ -103,14 +101,13 @@ ...@@ -103,14 +101,13 @@
{ {
[self ErrorMBProgressView:returnValue[@"message"]]; [self ErrorMBProgressView:returnValue[@"message"]];
} }
} WithErrorCodeBlock:^(id errorCodeValue) { } WithErrorCodeBlock:^(id errorCodeValue) {
[self RemoveMBProgressHUDLoding]; [self RemoveMBProgressHUDLoding];
[self ErrorMBProgressView:@"无网络"]; [self ErrorMBProgressView:@"无网络"];
} WithFailureBlock:^(id error) { } WithFailureBlock:^(NSError *error) {
[self RemoveMBProgressHUDLoding]; [self RemoveMBProgressHUDLoding];
[self ErrorMBProgressView:error.localizedDescription];
}]; }];
} }
......
...@@ -330,7 +330,7 @@ ...@@ -330,7 +330,7 @@
WS(weakSelf); WS(weakSelf);
[[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(CONFIRMPAY) WithRequestType:0 WithParameter:order WithReturnValueBlock:^(id returnValue) { [[NetworkRequestClassManager Manager] NetworkRequestWithURL:SERVERREQUESTURL(CONFIRMPAY) WithRequestType:0 WithParameter:order WithReturnValueBlock:^(id returnValue) {
[weakSelf CreateMBProgressHUDLoding]; [weakSelf RemoveMBProgressHUDLoding];
if ([returnValue[@"code"] isEqualToNumber:@0]) { if ([returnValue[@"code"] isEqualToNumber:@0]) {
NSLog(@"支付成功"); NSLog(@"支付成功");
[weakSelf ErrorMBProgressView:@"支付成功"]; [weakSelf ErrorMBProgressView:@"支付成功"];
......
...@@ -1821,8 +1821,8 @@ ...@@ -1821,8 +1821,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd";
COMPRESS_PNG_FILES = NO; COMPRESS_PNG_FILES = NO;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_SEARCH_PATHS = "$(inherited)";
...@@ -1865,7 +1865,7 @@ ...@@ -1865,7 +1865,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple; PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "10361169-d429-4810-90f6-528335fe4062";
STRIP_PNG_TEXT = NO; STRIP_PNG_TEXT = NO;
TARGETED_DEVICE_FAMILY = 2; TARGETED_DEVICE_FAMILY = 2;
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**"; USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
...@@ -1879,8 +1879,8 @@ ...@@ -1879,8 +1879,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd";
COMPRESS_PNG_FILES = NO; COMPRESS_PNG_FILES = NO;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)"; FRAMEWORK_SEARCH_PATHS = "$(inherited)";
...@@ -1923,7 +1923,7 @@ ...@@ -1923,7 +1923,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple; PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "10361169-d429-4810-90f6-528335fe4062";
STRIP_PNG_TEXT = NO; STRIP_PNG_TEXT = NO;
TARGETED_DEVICE_FAMILY = 2; TARGETED_DEVICE_FAMILY = 2;
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**"; USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string>欧立方</string> <string>欧立方</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0.8</string> <string>1.1.0</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
<array> <array>
<dict> <dict>
......
This diff is collapsed.
...@@ -18,7 +18,7 @@ PODS: ...@@ -18,7 +18,7 @@ PODS:
- DZNEmptyDataSet (1.8.1) - DZNEmptyDataSet (1.8.1)
- FDFullscreenPopGesture (1.1) - FDFullscreenPopGesture (1.1)
- IQKeyboardManager (4.0.6) - IQKeyboardManager (4.0.6)
- JSONModel (1.5.1) - JSONModel (1.2.0)
- Masonry (1.0.2) - Masonry (1.0.2)
- MBProgressHUD (1.0.0) - MBProgressHUD (1.0.0)
- MJExtension (3.0.13) - MJExtension (3.0.13)
...@@ -46,7 +46,7 @@ DEPENDENCIES: ...@@ -46,7 +46,7 @@ DEPENDENCIES:
- DZNEmptyDataSet - DZNEmptyDataSet
- FDFullscreenPopGesture - FDFullscreenPopGesture
- IQKeyboardManager - IQKeyboardManager
- JSONModel - JSONModel (~> 1.2.0)
- Masonry - Masonry
- MBProgressHUD - MBProgressHUD
- MJExtension - MJExtension
...@@ -61,7 +61,7 @@ SPEC CHECKSUMS: ...@@ -61,7 +61,7 @@ SPEC CHECKSUMS:
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7 DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0 FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0
IQKeyboardManager: c52debb1967799ae7addb98eab0cf328083a874f IQKeyboardManager: c52debb1967799ae7addb98eab0cf328083a874f
JSONModel: fd2553dc9e6608a3f35bfc956a14be35395d3852 JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c
Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e
MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a
MJExtension: 5932755f451458eefa24239358817f8d291240c7 MJExtension: 5932755f451458eefa24239358817f8d291240c7
......
../../../JSONModel/JSONModel/JSONModel/JSONModelArray.h
\ No newline at end of file
../../../JSONModel/JSONModel/JSONModelCategories/NSArray+JSONModel.h
\ No newline at end of file
../../../JSONModel/JSONModel/JSONModel/JSONModelArray.h
\ No newline at end of file
../../../JSONModel/JSONModel/JSONModelCategories/NSArray+JSONModel.h
\ No newline at end of file
//
// JSONModelArray.h
//
// @version 0.8.0
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h>
/**
* **Don't make instances of JSONModelArray yourself, except you know what you are doing.**
*
* You get automatically JSONModelArray instances, when you declare a convert on demand property, like so:
*
* @property (strong, nonatomic) NSArray&lt;JSONModel, ConvertOnDemand&gt;* list;
*
* The class stores its contents as they come from JSON, and upon the first request
* of each of the objects stored in the array, it'll be converted to the target model class.
* Thus saving time upon the very first model creation.
*/
@interface JSONModelArray : NSObject <NSFastEnumeration>
/**
* Don't make instances of JSONModelArray yourself, except you know what you are doing.
*
* @param array an array of NSDictionary objects
* @param cls the JSONModel sub-class you'd like the NSDictionaries to be converted to on demand
*/
- (id)initWithArray:(NSArray *)array modelClass:(Class)cls;
- (id)objectAtIndex:(NSUInteger)index;
- (id)objectAtIndexedSubscript:(NSUInteger)index;
- (void)forwardInvocation:(NSInvocation *)anInvocation;
- (NSUInteger)count;
- (id)firstObject;
- (id)lastObject;
/**
* Looks up the array's contents and tries to find a JSONModel object
* with matching index property value to the indexValue param.
*
* Will return nil if no matching model is found. Will return nil if there's no index property
* defined on the models found in the array (will sample the first object, assuming the array
* contains homogeneous collection of objects)
*
* @param indexValue the id value to search for
* @return the found model or nil
*/
- (id)modelWithIndexValue:(id)indexValue;
@end
//
// JSONModelArray.m
//
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import "JSONModelArray.h"
#import "JSONModel.h"
@implementation JSONModelArray
{
NSMutableArray* _storage;
Class _targetClass;
}
-(id)initWithArray:(NSArray *)array modelClass:(Class)cls
{
self = [super init];
if (self) {
_storage = [NSMutableArray arrayWithArray:array];
_targetClass = cls;
}
return self;
}
-(id)firstObject
{
return [self objectAtIndex:0];
}
-(id)lastObject
{
return [self objectAtIndex:_storage.count - 1];
}
-(id)objectAtIndex:(NSUInteger)index
{
return [self objectAtIndexedSubscript:index];
}
-(id)objectAtIndexedSubscript:(NSUInteger)index
{
id object = _storage[index];
if (![object isMemberOfClass:_targetClass]) {
NSError* err = nil;
object = [[_targetClass alloc] initWithDictionary:object error:&err];
if (object) {
_storage[index] = object;
}
}
return object;
}
-(void)forwardInvocation:(NSInvocation *)anInvocation
{
[anInvocation invokeWithTarget:_storage];
}
-(id)forwardingTargetForSelector:(SEL)selector
{
static NSArray *overriddenMethods = nil;
if (!overriddenMethods) overriddenMethods = @[@"initWithArray:modelClass:", @"objectAtIndex:", @"objectAtIndexedSubscript:", @"count", @"modelWithIndexValue:", @"description", @"mutableCopy", @"firstObject", @"lastObject", @"countByEnumeratingWithState:objects:count:"];
if ([overriddenMethods containsObject:NSStringFromSelector(selector)]) {
return self;
}
return _storage;
}
-(NSUInteger)count
{
return _storage.count;
}
-(id)modelWithIndexValue:(id)indexValue
{
if (self.count==0) return nil;
if (![_storage[0] indexPropertyName]) return nil;
for (JSONModel* model in _storage) {
if ([[model valueForKey:model.indexPropertyName] isEqual:indexValue]) {
return model;
}
}
return nil;
}
-(id)mutableCopy
{
//it's already mutable
return self;
}
#pragma mark - description
-(NSString*)description
{
NSMutableString* res = [NSMutableString stringWithFormat:@"<JSONModelArray[%@]>\n", [_targetClass description]];
for (id m in _storage) {
[res appendString: [m description]];
[res appendString: @",\n"];
}
[res appendFormat:@"\n</JSONModelArray>"];
return res;
}
-(NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
objects:(id __unsafe_unretained [])stackbuf
count:(NSUInteger)stackbufLength
{
NSUInteger count = 0;
unsigned long countOfItemsAlreadyEnumerated = state->state;
if (countOfItemsAlreadyEnumerated == 0) {
state->mutationsPtr = &state->extra[0];
}
if (countOfItemsAlreadyEnumerated < [self count]) {
state->itemsPtr = stackbuf;
while ((countOfItemsAlreadyEnumerated < [self count]) && (count < stackbufLength)) {
stackbuf[count] = [self objectAtIndex:countOfItemsAlreadyEnumerated];
countOfItemsAlreadyEnumerated++;
count++;
}
} else {
count = 0;
}
state->state = countOfItemsAlreadyEnumerated;
return count;
}
@end
// //
// JSONModelClassProperty.h // JSONModelClassProperty.h
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
enum kCustomizationTypes {
kNotInspected = 0,
kCustom,
kNo
};
typedef enum kCustomizationTypes PropertyGetterType;
/** /**
* **You do not need to instantiate this class yourself.** This class is used internally by JSONModel * **You do not need to instantiate this class yourself.** This class is used internally by JSONModel
* to inspect the declared properties of your model class. * to inspect the declared properties of your model class.
...@@ -15,20 +34,17 @@ ...@@ -15,20 +34,17 @@
*/ */
@interface JSONModelClassProperty : NSObject @interface JSONModelClassProperty : NSObject
// deprecated
@property (assign, nonatomic) BOOL isIndex DEPRECATED_ATTRIBUTE;
/** The name of the declared property (not the ivar name) */ /** The name of the declared property (not the ivar name) */
@property (copy, nonatomic) NSString *name; @property (copy, nonatomic) NSString* name;
/** A property class type */ /** A property class type */
@property (assign, nonatomic) Class type; @property (assign, nonatomic) Class type;
/** Struct name if a struct */ /** Struct name if a struct */
@property (strong, nonatomic) NSString *structName; @property (strong, nonatomic) NSString* structName;
/** The name of the protocol the property conforms to (or nil) */ /** The name of the protocol the property conforms to (or nil) */
@property (copy, nonatomic) NSString *protocol; @property (copy, nonatomic) NSString* protocol;
/** If YES, it can be missing in the input data, and the input would be still valid */ /** If YES, it can be missing in the input data, and the input would be still valid */
@property (assign, nonatomic) BOOL isOptional; @property (assign, nonatomic) BOOL isOptional;
...@@ -39,10 +55,19 @@ ...@@ -39,10 +55,19 @@
/** If YES - create a mutable object for the value of the property */ /** If YES - create a mutable object for the value of the property */
@property (assign, nonatomic) BOOL isMutable; @property (assign, nonatomic) BOOL isMutable;
/** If YES - create models on demand for the array members */
@property (assign, nonatomic) BOOL convertsOnDemand;
/** If YES - the value of this property determines equality to other models */
@property (assign, nonatomic) BOOL isIndex;
/** The status of property getter introspection in a model */
@property (assign, nonatomic) PropertyGetterType getterType;
/** a custom getter for this property, found in the owning model */ /** a custom getter for this property, found in the owning model */
@property (assign, nonatomic) SEL customGetter; @property (assign, nonatomic) SEL customGetter;
/** custom setters for this property, found in the owning model */ /** custom setters for this property, found in the owning model */
@property (strong, nonatomic) NSMutableDictionary *customSetters; @property (strong, nonatomic) NSMutableDictionary<NSString *, id> *customSetters;
@end @end
// //
// JSONModelClassProperty.m // JSONModelClassProperty.m
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import "JSONModelClassProperty.h" #import "JSONModelClassProperty.h"
...@@ -12,13 +23,10 @@ ...@@ -12,13 +23,10 @@
//build the properties string for the current class property //build the properties string for the current class property
NSMutableArray* properties = [NSMutableArray arrayWithCapacity:8]; NSMutableArray* properties = [NSMutableArray arrayWithCapacity:8];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if (self.isIndex) [properties addObject:@"Index"]; if (self.isIndex) [properties addObject:@"Index"];
#pragma GCC diagnostic pop
if (self.isOptional) [properties addObject:@"Optional"]; if (self.isOptional) [properties addObject:@"Optional"];
if (self.isMutable) [properties addObject:@"Mutable"]; if (self.isMutable) [properties addObject:@"Mutable"];
if (self.convertsOnDemand) [properties addObject:@"ConvertOnDemand"];
if (self.isStandardJSONType) [properties addObject:@"Standard JSON type"]; if (self.isStandardJSONType) [properties addObject:@"Standard JSON type"];
if (self.customGetter) [properties addObject:[NSString stringWithFormat: @"Getter = %@", NSStringFromSelector(self.customGetter)]]; if (self.customGetter) [properties addObject:[NSString stringWithFormat: @"Getter = %@", NSStringFromSelector(self.customGetter)]];
......
// //
// JSONModelError.h // JSONModelError.h
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
...@@ -17,7 +28,7 @@ typedef NS_ENUM(int, kJSONModelErrorTypes) ...@@ -17,7 +28,7 @@ typedef NS_ENUM(int, kJSONModelErrorTypes)
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
/** The domain name used for the JSONModelError instances */ /** The domain name used for the JSONModelError instances */
extern NSString *const JSONModelErrorDomain; extern NSString* const JSONModelErrorDomain;
/** /**
* If the model JSON input misses keys that are required, check the * If the model JSON input misses keys that are required, check the
...@@ -25,7 +36,7 @@ extern NSString *const JSONModelErrorDomain; ...@@ -25,7 +36,7 @@ extern NSString *const JSONModelErrorDomain;
* under the kJSONModelMissingKeys key you will find a list of the * under the kJSONModelMissingKeys key you will find a list of the
* names of the missing keys. * names of the missing keys.
*/ */
extern NSString *const kJSONModelMissingKeys; extern NSString* const kJSONModelMissingKeys;
/** /**
* If JSON input has a different type than expected by the model, check the * If JSON input has a different type than expected by the model, check the
...@@ -33,14 +44,14 @@ extern NSString *const kJSONModelMissingKeys; ...@@ -33,14 +44,14 @@ extern NSString *const kJSONModelMissingKeys;
* under the kJSONModelTypeMismatch key you will find a description * under the kJSONModelTypeMismatch key you will find a description
* of the mismatched types. * of the mismatched types.
*/ */
extern NSString *const kJSONModelTypeMismatch; extern NSString* const kJSONModelTypeMismatch;
/** /**
* If an error occurs in a nested model, check the userInfo dictionary of * If an error occurs in a nested model, check the userInfo dictionary of
* the JSONModelError instance you get back - under the kJSONModelKeyPath * the JSONModelError instance you get back - under the kJSONModelKeyPath
* key you will find key-path at which the error occurred. * key you will find key-path at which the error occurred.
*/ */
extern NSString *const kJSONModelKeyPath; extern NSString* const kJSONModelKeyPath;
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
/** /**
...@@ -49,46 +60,46 @@ extern NSString *const kJSONModelKeyPath; ...@@ -49,46 +60,46 @@ extern NSString *const kJSONModelKeyPath;
*/ */
@interface JSONModelError : NSError @interface JSONModelError : NSError
@property (strong, nonatomic) NSHTTPURLResponse *httpResponse; @property (strong, nonatomic) NSHTTPURLResponse* httpResponse;
@property (strong, nonatomic) NSData *responseData; @property (strong, nonatomic) NSData* responseData;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorInvalidData = 1 * Creates a JSONModelError instance with code kJSONModelErrorInvalidData = 1
*/ */
+ (id)errorInvalidDataWithMessage:(NSString *)message; +(id)errorInvalidDataWithMessage:(NSString*)message;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorInvalidData = 1 * Creates a JSONModelError instance with code kJSONModelErrorInvalidData = 1
* @param keys a set of field names that were required, but not found in the input * @param keys a set of field names that were required, but not found in the input
*/ */
+ (id)errorInvalidDataWithMissingKeys:(NSSet *)keys; +(id)errorInvalidDataWithMissingKeys:(NSSet*)keys;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorInvalidData = 1 * Creates a JSONModelError instance with code kJSONModelErrorInvalidData = 1
* @param mismatchDescription description of the type mismatch that was encountered. * @param mismatchDescription description of the type mismatch that was encountered.
*/ */
+ (id)errorInvalidDataWithTypeMismatch:(NSString *)mismatchDescription; +(id)errorInvalidDataWithTypeMismatch:(NSString*)mismatchDescription;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorBadResponse = 2 * Creates a JSONModelError instance with code kJSONModelErrorBadResponse = 2
*/ */
+ (id)errorBadResponse; +(id)errorBadResponse;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorBadJSON = 3 * Creates a JSONModelError instance with code kJSONModelErrorBadJSON = 3
*/ */
+ (id)errorBadJSON; +(id)errorBadJSON;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorModelIsInvalid = 4 * Creates a JSONModelError instance with code kJSONModelErrorModelIsInvalid = 4
*/ */
+ (id)errorModelIsInvalid; +(id)errorModelIsInvalid;
/** /**
* Creates a JSONModelError instance with code kJSONModelErrorNilInput = 5 * Creates a JSONModelError instance with code kJSONModelErrorNilInput = 5
*/ */
+ (id)errorInputIsNil; +(id)errorInputIsNil;
/** /**
* Creates a new JSONModelError with the same values plus information about the key-path of the error. * Creates a new JSONModelError with the same values plus information about the key-path of the error.
...@@ -97,7 +108,7 @@ extern NSString *const kJSONModelKeyPath; ...@@ -97,7 +108,7 @@ extern NSString *const kJSONModelKeyPath;
* This key contains the component string parameter. If the key is already present * This key contains the component string parameter. If the key is already present
* then the new error object has the component string prepended to the existing value. * then the new error object has the component string prepended to the existing value.
*/ */
- (instancetype)errorByPrependingKeyPathComponent:(NSString *)component; - (instancetype)errorByPrependingKeyPathComponent:(NSString*)component;
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
@end @end
// //
// JSONModelError.m // JSONModelError.m
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import "JSONModelError.h" #import "JSONModelError.h"
......
//
// NSArray+JSONModel.h
//
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h>
#import "JSONModel.h"
/**
* Exposes invisible JSONModelArray methods
*/
@interface NSArray(JSONModel)
/**
* Looks up the array's contents and tries to find a JSONModel object
* with matching index property value to the indexValue param.
*
* Will return nil if no matching model is found. Will return nil if there's no index property
* defined on the models found in the array (will sample the first object, assuming the array
* contains homogeneous collection of objects)
*
* @param indexValue the id value to search for
* @return the found model or nil
* @exception NSException throws exception if you call this method on an instance, which is not actually a JSONModelArray
*/
- (id)modelWithIndexValue:(id)indexValue;
@end
//
// NSArray+JSONModel.m
//
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import "NSArray+JSONModel.h"
@implementation NSArray(JSONModel)
- (id)modelWithIndexValue:(id)indexValue
{
NSAssert(NO, @"call modelWithIndexValue: on a ConvertOnDemand property, which is defined like that: @property (strong, nonatomic) NSArray<MyModel, ConvertOnDemand>* list;");
return nil;
}
@end
// //
// JSONModelLib.h // JSONModelLib.h
// JSONModel //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
// //
#import <Foundation/Foundation.h> // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// core
#import "JSONModel.h"
#import "JSONModelError.h"
// transformations #import <Foundation/Foundation.h>
//JSONModel transformations
#import "JSONValueTransformer.h" #import "JSONValueTransformer.h"
#import "JSONKeyMapper.h" #import "JSONKeyMapper.h"
// networking (deprecated) //basic JSONModel classes
#import "JSONModelError.h"
#import "JSONModelClassProperty.h"
#import "JSONModel.h"
//network classes
#import "JSONHTTPClient.h" #import "JSONHTTPClient.h"
#import "JSONModel+networking.h" #import "JSONModel+networking.h"
#import "JSONAPI.h" #import "JSONAPI.h"
//models array
#import "NSArray+JSONModel.h"
#import "JSONModelArray.h"
// //
// JSONAPI.h // JSONAPI.h
// JSONModel //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "JSONHTTPClient.h" #import "JSONHTTPClient.h"
DEPRECATED_ATTRIBUTE /////////////////////////////////////////////////////////////////////////////////////////////
/**
* @discussion Class for working with JSON APIs. It builds upon the JSONHTTPClient class
* and facilitates making requests to the same web host. Also features helper
* method for making calls to a JSON RPC service
*/
@interface JSONAPI : NSObject @interface JSONAPI : NSObject
+ (void)setAPIBaseURLWithString:(NSString *)base DEPRECATED_ATTRIBUTE; /////////////////////////////////////////////////////////////////////////////////////////////
+ (void)setContentType:(NSString *)ctype DEPRECATED_ATTRIBUTE;
+ (void)getWithPath:(NSString *)path andParams:(NSDictionary *)params completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE; /** @name Configuring the API */
+ (void)postWithPath:(NSString *)path andParams:(NSDictionary *)params completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE; /**
+ (void)rpcWithMethodName:(NSString *)method andArguments:(NSArray *)args completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE; * Sets the API url
+ (void)rpc2WithMethodName:(NSString *)method andParams:(id)params completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE; * @param base the API url as a string
*/
+(void)setAPIBaseURLWithString:(NSString*)base;
/**
* Sets the default content type for the requests/responses
* @param ctype The content-type as a string. Some possible types,
* depending on the service: application/json, text/json, x-application/javascript, etc.
*/
+(void)setContentType:(NSString*)ctype;
/////////////////////////////////////////////////////////////////////////////////////////////
/** @name Making GET API requests */
/**
* Makes an asynchronous GET request to the API
* @param path the URL path to add to the base API URL for this HTTP call
* @param params the variables to pass to the API
* @param completeBlock a JSONObjectBlock block to execute upon completion
*/
+(void)getWithPath:(NSString*)path andParams:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock;
/////////////////////////////////////////////////////////////////////////////////////////////
/** @name Making POST API requests */
/**
* Makes a POST request to the API
* @param path the URL path to add to the base API URL for this HTTP call
* @param params the variables to pass to the API
* @param completeBlock a JSONObjectBlock block to execute upon completion
*/
+(void)postWithPath:(NSString*)path andParams:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock;
/////////////////////////////////////////////////////////////////////////////////////////////
/** @name JSON RPC methods */
/**
* Makes an asynchronous JSON RPC request to the API. Read more: http://www.jsonrpc.org
* @param method the HTTP method name; GET or POST only
* @param args the list of arguments to pass to the API
* @param completeBlock JSONObjectBlock to execute upon completion
*/
+(void)rpcWithMethodName:(NSString*)method andArguments:(NSArray*)args completion:(JSONObjectBlock)completeBlock;
/** @name JSON RPC (2.0) request method */
/**
* Makes an asynchronous JSON RPC 2.0 request to the API. Read more: http://www.jsonrpc.org
* @param method the HTTP method name; GET or POST only
* @param params the params to pass to the API - an NSArray or an NSDictionary,
* depending whether you're using named or unnamed parameters
* @param completeBlock JSONObjectBlock to execute upon completion
*/
+(void)rpc2WithMethodName:(NSString*)method andParams:(id)params completion:(JSONObjectBlock)completeBlock;
/////////////////////////////////////////////////////////////////////////////////////////////
@end @end
// //
// JSONAPI.m // JSONAPI.m
// JSONModel //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
// //
#import "JSONAPI.h" // Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wdeprecated-implementations" #import "JSONAPI.h"
#pragma mark - helper error model class #pragma mark - helper error model class
@interface JSONAPIRPCErrorModel: JSONModel @interface JSONAPIRPCErrorModel: JSONModel
...@@ -18,7 +26,6 @@ ...@@ -18,7 +26,6 @@
#pragma mark - static variables #pragma mark - static variables
static JSONAPI* sharedInstance = nil; static JSONAPI* sharedInstance = nil;
static long jsonRpcId = 0; static long jsonRpcId = 0;
#pragma mark - JSONAPI() private interface #pragma mark - JSONAPI() private interface
......
// //
// JSONModelHTTPClient.m // JSONModelHTTPClient.m
// JSONModel //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
#import "JSONHTTPClient.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" #import "JSONHTTPClient.h"
#pragma GCC diagnostic ignored "-Wdeprecated-implementations"
typedef void (^RequestResultBlock)(NSData *data, JSONModelError *error); typedef void (^RequestResultBlock)(NSData *data, JSONModelError *error);
......
// //
// JSONModel+networking.h // JSONModel+networking.h
// JSONModel //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
#import "JSONModel.h" #import "JSONModel.h"
#import "JSONHTTPClient.h" #import "JSONHTTPClient.h"
typedef void (^JSONModelBlock)(id model, JSONModelError *err) DEPRECATED_ATTRIBUTE; typedef void (^JSONModelBlock)(id model, JSONModelError* err);
/**
* The JSONModel(networking) class category adds networking to JSONModel.
* It adds initFromURLWithString: initializer, which makes a GET http request
* to the URL given and initializes the model with the returned JSON.
* Use #import "JSONModel+networking.h" to import networking capabilities.
*/
@interface JSONModel(Networking)
@property (assign, nonatomic) BOOL isLoading;
/** @name Asynchronously create a model over the network */
/**
* Asynchronously create a model over the network. Create a new model instance and initialize it with the JSON fetched from the given URL
* @param urlString the absolute URL address of the JSON feed as a string
* @param completeBlock JSONModelBlock executed upon completion. The JSONModelBlock type is defined as: void (^JSONModelBlock)(JSONModel* model, JSONModelError* e); the first parameter is the initialized model or nil,
* and second parameter holds the model initialization error, if any
*/
-(instancetype)initFromURLWithString:(NSString *)urlString completion:(JSONModelBlock)completeBlock;
/**
* Asynchronously gets the contents of a URL and constructs a JSONModel object from the response.
* The constructed JSONModel object passed as the first parameter to the completion block will be of the same
* class as the receiver. So call this method on yourJSONModel sub-class rather than directly on JSONModel.
* @param urlString The absolute URL of the JSON resource, as a string
* @param completeBlock The block to be called upon completion.
* JSONModelBlock type is defined as: void (^JSONModelBlock)(JSONModel* model, JSONModelError* err);
* The first parameter is the initialized model (of the same JSONModel sub-class as the receiver) or nil if there was an error;
* The second parameter is the initialization error, if any.
*/
+ (void)getModelFromURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock;
@interface JSONModel (Networking) /**
* Asynchronously posts a JSONModel object (as JSON) to a URL and constructs a JSONModel object from the response.
* The constructed JSONModel object passed as the first parameter to the completion block will be of the same
* class as the receiver. So call this method on yourJSONModel sub-class rather than directly on JSONModel.
* @param post A JSONModel object that will be converted to JSON and sent as the POST data to the HTTP request.
* @param urlString The absolute URL of the JSON resource, as a string
* @param completeBlock The block to be called upon completion.
* JSONModelBlock type is defined as: void (^JSONModelBlock)(JSONModel* model, JSONModelError* err);
* The first parameter is the initialized model (of the same JSONModel sub-class as the receiver) or nil if there was an error;
* The second parameter is the initialization error, if any.
*/
+ (void)postModel:(JSONModel*)post toURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock;
@property (assign, nonatomic) BOOL isLoading DEPRECATED_ATTRIBUTE;
- (instancetype)initFromURLWithString:(NSString *)urlString completion:(JSONModelBlock)completeBlock DEPRECATED_ATTRIBUTE;
+ (void)getModelFromURLWithString:(NSString *)urlString completion:(JSONModelBlock)completeBlock DEPRECATED_ATTRIBUTE;
+ (void)postModel:(JSONModel *)post toURLWithString:(NSString *)urlString completion:(JSONModelBlock)completeBlock DEPRECATED_ATTRIBUTE;
@end @end
// //
// JSONModel+networking.m // JSONModel+networking.m
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import "JSONModel+networking.h" #import "JSONModel+networking.h"
#import "JSONHTTPClient.h" #import "JSONHTTPClient.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wdeprecated-implementations"
BOOL _isLoading; BOOL _isLoading;
@implementation JSONModel(Networking) @implementation JSONModel(Networking)
......
// //
// JSONKeyMapper.h // JSONKeyMapper.h
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
typedef NSString *(^JSONModelKeyMapBlock)(NSString *keyName); typedef NSString* (^JSONModelKeyMapBlock)(NSString* keyName);
/** /**
* **You won't need to create or store instances of this class yourself.** If you want your model * **You won't need to create or store instances of this class yourself.** If you want your model
...@@ -21,71 +32,71 @@ typedef NSString *(^JSONModelKeyMapBlock)(NSString *keyName); ...@@ -21,71 +32,71 @@ typedef NSString *(^JSONModelKeyMapBlock)(NSString *keyName);
* To comply with Obj-C accepted camelCase property naming for your classes, * To comply with Obj-C accepted camelCase property naming for your classes,
* you need to provide mapping between JSON keys and ObjC property names. * you need to provide mapping between JSON keys and ObjC property names.
* *
* In your model overwrite the + (JSONKeyMapper *)keyMapper method and provide a JSONKeyMapper * In your model overwrite the +(JSONKeyMapper*)keyMapper method and provide a JSONKeyMapper
* instance to convert the key names for your model. * instance to convert the key names for your model.
* *
* If you need custom mapping it's as easy as: * If you need custom mapping it's as easy as:
* <pre> * <pre>
* + (JSONKeyMapper *)keyMapper { * +(JSONKeyMapper*)keyMapper {
* &nbsp; return [[JSONKeyMapper&nbsp;alloc]&nbsp;initWithDictionary:@{@"crazy_JSON_name":@"myCamelCaseName"}]; * &nbsp; return [[JSONKeyMapper&nbsp;alloc]&nbsp;initWithDictionary:@{@"crazy_JSON_name":@"myCamelCaseName"}];
* } * }
* </pre> * </pre>
* In case you want to handle underscore_case, **use the predefined key mapper**, like so: * In case you want to handle underscore_case, **use the predefined key mapper**, like so:
* <pre> * <pre>
* + (JSONKeyMapper *)keyMapper { * +(JSONKeyMapper*)keyMapper {
* &nbsp; return [JSONKeyMapper&nbsp;mapperFromUnderscoreCaseToCamelCase]; * &nbsp; return [JSONKeyMapper&nbsp;mapperFromUnderscoreCaseToCamelCase];
* } * }
* </pre> * </pre>
*/ */
@interface JSONKeyMapper : NSObject @interface JSONKeyMapper : NSObject
// deprecated
@property (readonly, nonatomic) JSONModelKeyMapBlock JSONToModelKeyBlock DEPRECATED_ATTRIBUTE;
- (NSString *)convertValue:(NSString *)value isImportingToModel:(BOOL)importing DEPRECATED_MSG_ATTRIBUTE("use convertValue:");
- (instancetype)initWithDictionary:(NSDictionary *)map DEPRECATED_MSG_ATTRIBUTE("use initWithModelToJSONDictionary:");
- (instancetype)initWithJSONToModelBlock:(JSONModelKeyMapBlock)toModel modelToJSONBlock:(JSONModelKeyMapBlock)toJSON DEPRECATED_MSG_ATTRIBUTE("use initWithModelToJSONBlock:");
+ (instancetype)mapper:(JSONKeyMapper *)baseKeyMapper withExceptions:(NSDictionary *)exceptions DEPRECATED_MSG_ATTRIBUTE("use baseMapper:withModelToJSONExceptions:");
+ (instancetype)mapperFromUnderscoreCaseToCamelCase DEPRECATED_MSG_ATTRIBUTE("use mapperForSnakeCase:");
+ (instancetype)mapperFromUpperCaseToLowerCase DEPRECATED_ATTRIBUTE;
/** @name Name converters */ /** @name Name converters */
/** Block, which takes in a JSON key and converts it to the corresponding property name */
@property (readonly, nonatomic) JSONModelKeyMapBlock JSONToModelKeyBlock;
/** Block, which takes in a property name and converts it to the corresponding JSON key name */ /** Block, which takes in a property name and converts it to the corresponding JSON key name */
@property (readonly, nonatomic) JSONModelKeyMapBlock modelToJSONKeyBlock; @property (readonly, nonatomic) JSONModelKeyMapBlock modelToJSONKeyBlock;
/** Combined converter method /** Combined converter method
* @param value the source name * @param value the source name
* @return JSONKeyMapper instance * @param importing YES invokes JSONToModelKeyBlock, NO - modelToJSONKeyBlock
*/ * @return JSONKeyMapper instance
- (NSString *)convertValue:(NSString *)value; */
-(NSString*)convertValue:(NSString*)value isImportingToModel:(BOOL)importing;
/** @name Creating a key mapper */ /** @name Creating a key mapper */
/** /**
* Creates a JSONKeyMapper instance, based on the block you provide this initializer. * Creates a JSONKeyMapper instance, based on the two blocks you provide this initializer.
* The parameter takes in a JSONModelKeyMapBlock block: * The two parameters take in a JSONModelKeyMapBlock block:
* <pre>NSString *(^JSONModelKeyMapBlock)(NSString *keyName)</pre> * <pre>NSString* (^JSONModelKeyMapBlock)(NSString* keyName)</pre>
* The block takes in a string and returns the transformed (if at all) string. * The block takes in a string and returns the transformed (if at all) string.
* @param toModel transforms JSON key name to your model property name
* @param toJSON transforms your model property name to a JSON key * @param toJSON transforms your model property name to a JSON key
*/ */
- (instancetype)initWithModelToJSONBlock:(JSONModelKeyMapBlock)toJSON; -(instancetype)initWithJSONToModelBlock:(JSONModelKeyMapBlock)toModel
modelToJSONBlock:(JSONModelKeyMapBlock)toJSON;
/** /**
* Creates a JSONKeyMapper instance, based on the mapping you provide. * Creates a JSONKeyMapper instance, based on the mapping you provide
* Use your JSONModel property names as keys, and the JSON key names as values. * in the map parameter. Use the JSON key names as keys, your JSONModel
* @param toJSON map dictionary, in the format: <pre>@{@"myCamelCaseName":@"crazy_JSON_name"}</pre> * property names as values.
* @param map map dictionary, in the format: <pre>@{@"crazy_JSON_name":@"myCamelCaseName"}</pre>
* @return JSONKeyMapper instance * @return JSONKeyMapper instance
*/ */
- (instancetype)initWithModelToJSONDictionary:(NSDictionary *)toJSON; -(instancetype)initWithDictionary:(NSDictionary*)map;
/** /**
* Given a camelCase model property, this mapper finds JSON keys using the snake_case equivalent. * Creates a JSONKeyMapper, which converts underscore_case to camelCase and vice versa.
*/ */
+ (instancetype)mapperForSnakeCase; +(instancetype)mapperFromUnderscoreCaseToCamelCase;
+(instancetype)mapperFromUpperCaseToLowerCase;
/** /**
* Creates a JSONKeyMapper based on a built-in JSONKeyMapper, with specific exceptions. * Creates a JSONKeyMapper based on a built-in JSONKeyMapper, with specific exceptions.
* Use your JSONModel property names as keys, and the JSON key names as values. * Use the original JSON key names as keys, and your JSONModel property names as values.
*/ */
+ (instancetype)baseMapper:(JSONKeyMapper *)baseKeyMapper withModelToJSONExceptions:(NSDictionary *)toJSON; + (instancetype)mapper:(JSONKeyMapper *)baseKeyMapper withExceptions:(NSDictionary *)exceptions;
@end @end
// //
// JSONValueTransformer.h // JSONValueTransformer.h
// JSONModel
// //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "JSONModelArray.h"
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
...@@ -32,7 +44,7 @@ extern BOOL isNull(id value); ...@@ -32,7 +44,7 @@ extern BOOL isNull(id value);
*/ */
@interface JSONValueTransformer : NSObject @interface JSONValueTransformer : NSObject
@property (strong, nonatomic, readonly) NSDictionary *primitivesNames; @property (strong, nonatomic, readonly) NSDictionary* primitivesNames;
/** @name Resolving cluster class names */ /** @name Resolving cluster class names */
/** /**
...@@ -42,7 +54,7 @@ extern BOOL isNull(id value); ...@@ -42,7 +54,7 @@ extern BOOL isNull(id value);
* @param sourceClass the class to get the umbrella class for * @param sourceClass the class to get the umbrella class for
* @return Class * @return Class
*/ */
+ (Class)classByResolvingClusterClasses:(Class)sourceClass; +(Class)classByResolvingClusterClasses:(Class)sourceClass;
#pragma mark - NSMutableString <-> NSString #pragma mark - NSMutableString <-> NSString
/** @name Transforming to Mutable copies */ /** @name Transforming to Mutable copies */
...@@ -51,7 +63,7 @@ extern BOOL isNull(id value); ...@@ -51,7 +63,7 @@ extern BOOL isNull(id value);
* @param string incoming string * @param string incoming string
* @return mutable string * @return mutable string
*/ */
- (NSMutableString *)NSMutableStringFromNSString:(NSString *)string; -(NSMutableString*)NSMutableStringFromNSString:(NSString*)string;
#pragma mark - NSMutableArray <-> NSArray #pragma mark - NSMutableArray <-> NSArray
/** /**
...@@ -59,7 +71,16 @@ extern BOOL isNull(id value); ...@@ -59,7 +71,16 @@ extern BOOL isNull(id value);
* @param array incoming array * @param array incoming array
* @return mutable array * @return mutable array
*/ */
- (NSMutableArray *)NSMutableArrayFromNSArray:(NSArray *)array; -(NSMutableArray*)NSMutableArrayFromNSArray:(NSArray*)array;
#pragma mark - NS(Mutable)Array <- JSONModelArray
/**
* Transforms an array to a JSONModelArray
* @param array incoming array
* @return JSONModelArray
*/
-(NSArray*)NSArrayFromJSONModelArray:(JSONModelArray*)array;
-(NSMutableArray*)NSMutableArrayFromJSONModelArray:(JSONModelArray*)array;
#pragma mark - NSMutableDictionary <-> NSDictionary #pragma mark - NSMutableDictionary <-> NSDictionary
/** /**
...@@ -67,7 +88,7 @@ extern BOOL isNull(id value); ...@@ -67,7 +88,7 @@ extern BOOL isNull(id value);
* @param dict incoming dictionary * @param dict incoming dictionary
* @return mutable dictionary * @return mutable dictionary
*/ */
- (NSMutableDictionary *)NSMutableDictionaryFromNSDictionary:(NSDictionary *)dict; -(NSMutableDictionary*)NSMutableDictionaryFromNSDictionary:(NSDictionary*)dict;
#pragma mark - NSSet <-> NSArray #pragma mark - NSSet <-> NSArray
/** @name Transforming Sets */ /** @name Transforming Sets */
...@@ -76,28 +97,28 @@ extern BOOL isNull(id value); ...@@ -76,28 +97,28 @@ extern BOOL isNull(id value);
* @param array incoming array * @param array incoming array
* @return set with the array's elements * @return set with the array's elements
*/ */
- (NSSet *)NSSetFromNSArray:(NSArray *)array; -(NSSet*)NSSetFromNSArray:(NSArray*)array;
/** /**
* Transforms an array to a mutable set * Transforms an array to a mutable set
* @param array incoming array * @param array incoming array
* @return mutable set with the array's elements * @return mutable set with the array's elements
*/ */
- (NSMutableSet *)NSMutableSetFromNSArray:(NSArray *)array; -(NSMutableSet*)NSMutableSetFromNSArray:(NSArray*)array;
/** /**
* Transforms a set to an array * Transforms a set to an array
* @param set incoming set * @param set incoming set
* @return an array with the set's elements * @return an array with the set's elements
*/ */
- (NSArray *)JSONObjectFromNSSet:(NSSet *)set; -(NSArray*)JSONObjectFromNSSet:(NSSet*)set;
/** /**
* Transforms a mutable set to an array * Transforms a mutable set to an array
* @param set incoming mutable set * @param set incoming mutable set
* @return an array with the set's elements * @return an array with the set's elements
*/ */
- (NSArray *)JSONObjectFromNSMutableSet:(NSMutableSet *)set; -(NSArray*)JSONObjectFromNSMutableSet:(NSMutableSet*)set;
#pragma mark - BOOL <-> number/string #pragma mark - BOOL <-> number/string
/** @name Transforming JSON types */ /** @name Transforming JSON types */
...@@ -106,21 +127,21 @@ extern BOOL isNull(id value); ...@@ -106,21 +127,21 @@ extern BOOL isNull(id value);
* @param number the number to convert * @param number the number to convert
* @return the resulting number * @return the resulting number
*/ */
- (NSNumber *)BOOLFromNSNumber:(NSNumber *)number; -(NSNumber*)BOOLFromNSNumber:(NSNumber*)number;
/** /**
* Transforms a number object to a bool number object * Transforms a number object to a bool number object
* @param string the string value to convert, "0" converts to NO, everything else to YES * @param string the string value to convert, "0" converts to NO, everything else to YES
* @return the resulting number * @return the resulting number
*/ */
- (NSNumber *)BOOLFromNSString:(NSString *)string; -(NSNumber*)BOOLFromNSString:(NSString*)string;
/** /**
* Transforms a BOOL value to a bool number object * Transforms a BOOL value to a bool number object
* @param number an NSNumber value coming from the model * @param number an NSNumber value coming from the model
* @return the result number * @return the result number
*/ */
- (NSNumber *)JSONObjectFromBOOL:(NSNumber *)number; -(NSNumber*)JSONObjectFromBOOL:(NSNumber*)number;
#pragma mark - string <-> number #pragma mark - string <-> number
/** /**
...@@ -128,28 +149,28 @@ extern BOOL isNull(id value); ...@@ -128,28 +149,28 @@ extern BOOL isNull(id value);
* @param string the string to convert * @param string the string to convert
* @return the resulting number * @return the resulting number
*/ */
- (NSNumber *)NSNumberFromNSString:(NSString *)string; -(NSNumber*)NSNumberFromNSString:(NSString*)string;
/** /**
* Transforms a number object to a string object * Transforms a number object to a string object
* @param number the number to convert * @param number the number to convert
* @return the resulting string * @return the resulting string
*/ */
- (NSString *)NSStringFromNSNumber:(NSNumber *)number; -(NSString*)NSStringFromNSNumber:(NSNumber*)number;
/** /**
* Transforms a string object to a nsdecimalnumber object * Transforms a string object to a nsdecimalnumber object
* @param string the string to convert * @param string the string to convert
* @return the resulting number * @return the resulting number
*/ */
- (NSDecimalNumber *)NSDecimalNumberFromNSString:(NSString *)string; -(NSDecimalNumber*)NSDecimalNumberFromNSString:(NSString*)string;
/** /**
* Transforms a nsdecimalnumber object to a string object * Transforms a nsdecimalnumber object to a string object
* @param number the number to convert * @param number the number to convert
* @return the resulting string * @return the resulting string
*/ */
- (NSString *)NSStringFromNSDecimalNumber:(NSDecimalNumber *)number; -(NSString*)NSStringFromNSDecimalNumber:(NSDecimalNumber*)number;
#pragma mark - string <-> url #pragma mark - string <-> url
...@@ -159,14 +180,14 @@ extern BOOL isNull(id value); ...@@ -159,14 +180,14 @@ extern BOOL isNull(id value);
* @param string the string to convert * @param string the string to convert
* @return the resulting url object * @return the resulting url object
*/ */
- (NSURL *)NSURLFromNSString:(NSString *)string; -(NSURL*)NSURLFromNSString:(NSString*)string;
/** /**
* Transforms an NSURL object to a string * Transforms an NSURL object to a string
* @param url the url object to convert * @param url the url object to convert
* @return the resulting string * @return the resulting string
*/ */
- (NSString *)JSONObjectFromNSURL:(NSURL *)url; -(NSString*)JSONObjectFromNSURL:(NSURL*)url;
#pragma mark - string <-> time zone #pragma mark - string <-> time zone
...@@ -176,7 +197,7 @@ extern BOOL isNull(id value); ...@@ -176,7 +197,7 @@ extern BOOL isNull(id value);
* @param string the string to convert * @param string the string to convert
* @return the resulting NSTimeZone object * @return the resulting NSTimeZone object
*/ */
- (NSTimeZone *)NSTimeZoneFromNSString:(NSString *)string; - (NSTimeZone *)NSTimeZoneFromNSString:(NSString*)string;
/** /**
* Transforms an NSTimeZone object to a string * Transforms an NSTimeZone object to a string
...@@ -194,8 +215,8 @@ extern BOOL isNull(id value); ...@@ -194,8 +215,8 @@ extern BOOL isNull(id value);
* them in a category, so they have to stay hidden here. * them in a category, so they have to stay hidden here.
*/ */
//- (NSDate *)NSDateFromNSString:(NSString *)string; //-(NSDate*)NSDateFromNSString:(NSString*)string;
//- (NSString *)JSONObjectFromNSDate:(NSDate *)date; //-(NSString*)JSONObjectFromNSDate:(NSDate*)date;
#pragma mark - number <-> date #pragma mark - number <-> date
...@@ -204,6 +225,6 @@ extern BOOL isNull(id value); ...@@ -204,6 +225,6 @@ extern BOOL isNull(id value);
* @param number the number to convert * @param number the number to convert
* @return the resulting date * @return the resulting date
*/ */
- (NSDate *)NSDateFromNSNumber:(NSNumber *)number; - (NSDate*)NSDateFromNSNumber:(NSNumber*)number;
@end @end
// //
// JSONValueTransformer.m // JSONValueTransformer.m
// JSONModel //
// @version 1.2
// @author Marin Todorov (http://www.underplot.com) and contributors
//
// Copyright (c) 2012-2015 Marin Todorov, Underplot ltd.
// This code is distributed under the terms and conditions of the MIT license.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
#import "JSONValueTransformer.h" #import "JSONValueTransformer.h"
#import "JSONModelArray.h"
#pragma mark - functions #pragma mark - functions
extern BOOL isNull(id value) extern BOOL isNull(id value)
...@@ -70,9 +82,26 @@ extern BOOL isNull(id value) ...@@ -70,9 +82,26 @@ extern BOOL isNull(id value)
#pragma mark - NSMutableArray <-> NSArray #pragma mark - NSMutableArray <-> NSArray
-(NSMutableArray*)NSMutableArrayFromNSArray:(NSArray*)array -(NSMutableArray*)NSMutableArrayFromNSArray:(NSArray*)array
{ {
if ([array isKindOfClass:[JSONModelArray class]]) {
//it's a jsonmodelarray already, just return it
return (id)array;
}
return [NSMutableArray arrayWithArray:array]; return [NSMutableArray arrayWithArray:array];
} }
#pragma mark - NS(Mutable)Array <- JSONModelArray
-(NSArray*)NSArrayFromJSONModelArray:(JSONModelArray*)array
{
return (NSMutableArray*)array;
}
-(NSMutableArray*)NSMutableArrayFromJSONModelArray:(JSONModelArray*)array
{
return (NSMutableArray*)array;
}
#pragma mark - NSMutableDictionary <-> NSDictionary #pragma mark - NSMutableDictionary <-> NSDictionary
-(NSMutableDictionary*)NSMutableDictionaryFromNSDictionary:(NSDictionary*)dict -(NSMutableDictionary*)NSMutableDictionaryFromNSDictionary:(NSDictionary*)dict
{ {
...@@ -150,7 +179,7 @@ extern BOOL isNull(id value) ...@@ -150,7 +179,7 @@ extern BOOL isNull(id value)
#pragma mark - string <-> number #pragma mark - string <-> number
-(NSNumber*)NSNumberFromNSString:(NSString*)string -(NSNumber*)NSNumberFromNSString:(NSString*)string
{ {
return [NSNumber numberWithDouble:[string doubleValue]]; return [NSNumber numberWithFloat: [string doubleValue]];
} }
-(NSString*)NSStringFromNSNumber:(NSNumber*)number -(NSString*)NSStringFromNSNumber:(NSNumber*)number
...@@ -172,7 +201,7 @@ extern BOOL isNull(id value) ...@@ -172,7 +201,7 @@ extern BOOL isNull(id value)
-(NSURL*)NSURLFromNSString:(NSString*)string -(NSURL*)NSURLFromNSString:(NSString*)string
{ {
// do not change this behavior - there are other ways of overriding it // do not change this behavior - there are other ways of overriding it
// see: https://github.com/jsonmodel/jsonmodel/pull/119 // see: https://github.com/icanzilb/JSONModel/pull/119
return [NSURL URLWithString:string]; return [NSURL URLWithString:string];
} }
...@@ -229,7 +258,7 @@ extern BOOL isNull(id value) ...@@ -229,7 +258,7 @@ extern BOOL isNull(id value)
} }
#pragma mark - hidden transform for empty dictionaries #pragma mark - hidden transform for empty dictionaries
//https://github.com/jsonmodel/jsonmodel/issues/163 //https://github.com/icanzilb/JSONModel/issues/163
-(NSDictionary*)__NSDictionaryFromNSArray:(NSArray*)array -(NSDictionary*)__NSDictionaryFromNSArray:(NSArray*)array
{ {
if (array.count==0) return @{}; if (array.count==0) return @{};
......
Copyright (c) 2012-2016 Marin Todorov and JSONModel contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
JSONModel
Copyright (c) 2012-2014 Marin Todorov, Underplot ltd.
This code is distributed under the terms and conditions of the MIT license.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License in plain English: http://www.touch-code-magazine.com/JSONModel/MITLicense
This diff is collapsed.
...@@ -18,7 +18,7 @@ PODS: ...@@ -18,7 +18,7 @@ PODS:
- DZNEmptyDataSet (1.8.1) - DZNEmptyDataSet (1.8.1)
- FDFullscreenPopGesture (1.1) - FDFullscreenPopGesture (1.1)
- IQKeyboardManager (4.0.6) - IQKeyboardManager (4.0.6)
- JSONModel (1.5.1) - JSONModel (1.2.0)
- Masonry (1.0.2) - Masonry (1.0.2)
- MBProgressHUD (1.0.0) - MBProgressHUD (1.0.0)
- MJExtension (3.0.13) - MJExtension (3.0.13)
...@@ -46,7 +46,7 @@ DEPENDENCIES: ...@@ -46,7 +46,7 @@ DEPENDENCIES:
- DZNEmptyDataSet - DZNEmptyDataSet
- FDFullscreenPopGesture - FDFullscreenPopGesture
- IQKeyboardManager - IQKeyboardManager
- JSONModel - JSONModel (~> 1.2.0)
- Masonry - Masonry
- MBProgressHUD - MBProgressHUD
- MJExtension - MJExtension
...@@ -61,7 +61,7 @@ SPEC CHECKSUMS: ...@@ -61,7 +61,7 @@ SPEC CHECKSUMS:
DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7 DZNEmptyDataSet: 9525833b9e68ac21c30253e1d3d7076cc828eaa7
FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0 FDFullscreenPopGesture: a8a620179e3d9c40e8e00256dcee1c1a27c6d0f0
IQKeyboardManager: c52debb1967799ae7addb98eab0cf328083a874f IQKeyboardManager: c52debb1967799ae7addb98eab0cf328083a874f
JSONModel: fd2553dc9e6608a3f35bfc956a14be35395d3852 JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c
Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e Masonry: 7c429b56da9d4ee0bbb3ed77a5ea710d6a5df39e
MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a MBProgressHUD: 4890f671c94e8a0f3cf959aa731e9de2f036d71a
MJExtension: 5932755f451458eefa24239358817f8d291240c7 MJExtension: 5932755f451458eefa24239358817f8d291240c7
......
This diff is collapsed.
...@@ -98,24 +98,29 @@ SOFTWARE. ...@@ -98,24 +98,29 @@ SOFTWARE.
## JSONModel ## JSONModel
Copyright (c) 2012-2016 Marin Todorov and JSONModel contributors JSONModel
Copyright (c) 2012-2014 Marin Todorov, Underplot ltd.
This code is distributed under the terms and conditions of the MIT license.
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in the
the Software without restriction, including without limitation the rights to Software without restriction, including without limitation the rights to use, copy,
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
the Software, and to permit persons to whom the Software is furnished to do so, and to permit persons to whom the Software is furnished to do so, subject to the
subject to the following conditions: following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License in plain English: http://www.touch-code-magazine.com/JSONModel/MITLicense
## MBProgressHUD ## MBProgressHUD
......
...@@ -129,24 +129,29 @@ SOFTWARE. ...@@ -129,24 +129,29 @@ SOFTWARE.
</dict> </dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>Copyright (c) 2012-2016 Marin Todorov and JSONModel contributors <string>JSONModel
Copyright (c) 2012-2014 Marin Todorov, Underplot ltd.
This code is distributed under the terms and conditions of the MIT license.
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in the
the Software without restriction, including without limitation the rights to Software without restriction, including without limitation the rights to use, copy,
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
the Software, and to permit persons to whom the Software is furnished to do so, and to permit persons to whom the Software is furnished to do so, subject to the
subject to the following conditions: following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License in plain English: http://www.touch-code-magazine.com/JSONModel/MITLicense
</string> </string>
<key>Title</key> <key>Title</key>
<string>JSONModel</string> <string>JSONModel</string>
......
...@@ -117,12 +117,12 @@ ...@@ -117,12 +117,12 @@
/** /**
* 服务器测试地址 * 服务器测试地址
*/ */
#define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg-dev.opple.com/opple-web/app%@",URL] //#define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg-dev.opple.com/opple-web/app%@",URL]
///** ///**
// * 服务器正式地址 // * 服务器正式地址
// */ // */
//#define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg.opple.com/opple-web/app%@",URL] #define SERVERREQUESTURL(URL) [NSString stringWithFormat:@"http://dg.opple.com/opple-web/app%@",URL]
/** /**
* 搜索框输入通知 * 搜索框输入通知
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"newPassword": @"fnewPassword", @"newPassword": @"fnewPassword",
}]; }];
} }
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"newstate": @"fnewstate", @"newstate": @"fnewstate",
}]; }];
} }
...@@ -271,7 +271,7 @@ ...@@ -271,7 +271,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -325,7 +325,7 @@ ...@@ -325,7 +325,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -354,7 +354,7 @@ ...@@ -354,7 +354,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"description": @"fdescription", @"description": @"fdescription",
@"id": @"fid", @"id": @"fid",
}]; }];
...@@ -379,7 +379,7 @@ ...@@ -379,7 +379,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -422,7 +422,7 @@ ...@@ -422,7 +422,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -446,7 +446,7 @@ ...@@ -446,7 +446,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -474,7 +474,7 @@ ...@@ -474,7 +474,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -505,7 +505,7 @@ ...@@ -505,7 +505,7 @@
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -528,7 +528,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -528,7 +528,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -553,7 +553,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -553,7 +553,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -585,7 +585,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -585,7 +585,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -608,7 +608,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -608,7 +608,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -632,7 +632,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -632,7 +632,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -687,7 +687,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -687,7 +687,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -745,7 +745,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -745,7 +745,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -775,7 +775,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -775,7 +775,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"id": @"fid", @"id": @"fid",
}]; }];
} }
...@@ -877,7 +877,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -877,7 +877,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"newPassword": @"fnewPassword", @"newPassword": @"fnewPassword",
}]; }];
} }
...@@ -982,7 +982,7 @@ NSString * const SORTDIRECTION_DESC = @"desc"; ...@@ -982,7 +982,7 @@ NSString * const SORTDIRECTION_DESC = @"desc";
+(JSONKeyMapper*)keyMapper +(JSONKeyMapper*)keyMapper
{ {
return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{ return [[JSONKeyMapper alloc] initWithDictionary:@{
@"description": @"fdescription", @"description": @"fdescription",
}]; }];
} }
......
...@@ -9,7 +9,7 @@ pod 'Masonry' ...@@ -9,7 +9,7 @@ pod 'Masonry'
pod 'MJRefresh' pod 'MJRefresh'
pod 'SDWebImage' pod 'SDWebImage'
pod 'AFNetworking' pod 'AFNetworking'
pod 'JSONModel' pod 'JSONModel', '~> 1.2.0'
pod 'UMengSocial' pod 'UMengSocial'
pod 'DZNEmptyDataSet' pod 'DZNEmptyDataSet'
pod 'Bugly' pod 'Bugly'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment