Commit fa4413dc authored by Sandy's avatar Sandy

Merge branch 'master' of https://git.oschina.net/gomore/total

Conflicts:
	total/GTOApp/Business/Repair/Views/GTOLicenceBoltView.m
	total/Info.plist
	total/Macro/GTOAppMacro.h
parents 9ee92af1 9bd516fb
...@@ -32,7 +32,7 @@ PODS: ...@@ -32,7 +32,7 @@ PODS:
- FMDB/standard (2.6.2) - FMDB/standard (2.6.2)
- IQKeyboardManager (3.2.4) - IQKeyboardManager (3.2.4)
- JPushSDK (1.8.2) - JPushSDK (1.8.2)
- JSONModel (1.2.0) - JSONModel (1.7.0)
- Masonry (1.0.1) - Masonry (1.0.1)
- MBProgressHUD (0.9.2) - MBProgressHUD (0.9.2)
- MJRefresh (3.1.3) - MJRefresh (3.1.3)
...@@ -57,7 +57,7 @@ DEPENDENCIES: ...@@ -57,7 +57,7 @@ DEPENDENCIES:
- FMDB (~> 2.5) - FMDB (~> 2.5)
- IQKeyboardManager (~> 3.2.3) - IQKeyboardManager (~> 3.2.3)
- JPushSDK (~> 1.8.2) - JPushSDK (~> 1.8.2)
- JSONModel (~> 1.2.0) - JSONModel (~> 1.7.0)
- Masonry (~> 1.0.1) - Masonry (~> 1.0.1)
- MBProgressHUD (~> 0.9.1) - MBProgressHUD (~> 0.9.1)
- MJRefresh (~> 3.1.0) - MJRefresh (~> 3.1.0)
...@@ -76,7 +76,7 @@ SPEC CHECKSUMS: ...@@ -76,7 +76,7 @@ SPEC CHECKSUMS:
FMDB: 854a0341b4726e53276f2a8996f06f1b80f9259a FMDB: 854a0341b4726e53276f2a8996f06f1b80f9259a
IQKeyboardManager: 555b1231fefafb21b19278d7cca72986a27b748b IQKeyboardManager: 555b1231fefafb21b19278d7cca72986a27b748b
JPushSDK: c68dd04c595a5c93aa003f212974010790410d8e JPushSDK: c68dd04c595a5c93aa003f212974010790410d8e
JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c JSONModel: 840bc0fcffb24b8454d2c026bf26fea454b8e98d
Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df
MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1 MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1
MJRefresh: e9005c294dd8a3d08cc7c50eea2b5016673f29c4 MJRefresh: e9005c294dd8a3d08cc7c50eea2b5016673f29c4
......
../../../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.
* *
* Class to contain the information, representing a class property * Class to contain the information, representing a class property
* It features the property's name, type, whether it's a required property, * It features the property's name, type, whether it's a required property,
* and (optionally) the class protocol * and (optionally) the class protocol
*/ */
@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;
...@@ -55,19 +39,10 @@ typedef enum kCustomizationTypes PropertyGetterType; ...@@ -55,19 +39,10 @@ typedef enum kCustomizationTypes PropertyGetterType;
/** 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<NSString *, id> *customSetters; @property (strong, nonatomic) NSMutableDictionary *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"
...@@ -22,11 +11,14 @@ ...@@ -22,11 +11,14 @@
{ {
//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)]];
...@@ -36,18 +28,19 @@ ...@@ -36,18 +28,19 @@
for (id obj in self.customSetters.allValues) for (id obj in self.customSetters.allValues)
{ {
if (obj != [NSNull null]) SEL selector;
[setters addObject:obj]; [obj getValue:&selector];
[setters addObject:NSStringFromSelector(selector)];
} }
[properties addObject:[NSString stringWithFormat: @"Setters = [%@]", [setters componentsJoinedByString:@", "]]]; [properties addObject:[NSString stringWithFormat: @"Setters = [%@]", [setters componentsJoinedByString:@", "]]];
} }
NSString* propertiesString = @""; NSString* propertiesString = @"";
if (properties.count>0) { if (properties.count>0) {
propertiesString = [NSString stringWithFormat:@"(%@)", [properties componentsJoinedByString:@", "]]; propertiesString = [NSString stringWithFormat:@"(%@)", [properties componentsJoinedByString:@", "]];
} }
//return the name, type and additional properties //return the name, type and additional properties
return [NSString stringWithFormat:@"@property %@%@ %@ %@", return [NSString stringWithFormat:@"@property %@%@ %@ %@",
self.type?[NSString stringWithFormat:@"%@*",self.type]:(self.structName?self.structName:@"primitive"), self.type?[NSString stringWithFormat:@"%@*",self.type]:(self.structName?self.structName:@"primitive"),
......
// //
// 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>
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
...@@ -28,15 +17,15 @@ typedef NS_ENUM(int, kJSONModelErrorTypes) ...@@ -28,15 +17,15 @@ 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
* userInfo dictionary of the JSONModelError instance you get back - * userInfo dictionary of the JSONModelError instance you get back -
* 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
...@@ -44,62 +33,62 @@ extern NSString* const kJSONModelMissingKeys; ...@@ -44,62 +33,62 @@ 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;
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
/** /**
* Custom NSError subclass with shortcut methods for creating * Custom NSError subclass with shortcut methods for creating
* the common JSONModel errors * the common JSONModel errors
*/ */
@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.
...@@ -108,7 +97,7 @@ extern NSString* const kJSONModelKeyPath; ...@@ -108,7 +97,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"
...@@ -25,7 +14,7 @@ NSString* const kJSONModelKeyPath = @"kJSONModelKeyPath"; ...@@ -25,7 +14,7 @@ NSString* const kJSONModelKeyPath = @"kJSONModelKeyPath";
+(id)errorInvalidDataWithMessage:(NSString*)message +(id)errorInvalidDataWithMessage:(NSString*)message
{ {
message = [NSString stringWithFormat:@"Invalid JSON data: %@", message]; message = [NSString stringWithFormat:@"Invalid JSON data: %@", message];
return [JSONModelError errorWithDomain:JSONModelErrorDomain return [JSONModelError errorWithDomain:JSONModelErrorDomain
code:kJSONModelErrorInvalidData code:kJSONModelErrorInvalidData
userInfo:@{NSLocalizedDescriptionKey:message}]; userInfo:@{NSLocalizedDescriptionKey:message}];
...@@ -56,7 +45,7 @@ NSString* const kJSONModelKeyPath = @"kJSONModelKeyPath"; ...@@ -56,7 +45,7 @@ NSString* const kJSONModelKeyPath = @"kJSONModelKeyPath";
{ {
return [JSONModelError errorWithDomain:JSONModelErrorDomain return [JSONModelError errorWithDomain:JSONModelErrorDomain
code:kJSONModelErrorBadJSON code:kJSONModelErrorBadJSON
userInfo:@{NSLocalizedDescriptionKey:@"Malformed JSON. Check the JSONModel data input."}]; userInfo:@{NSLocalizedDescriptionKey:@"Malformed JSON. Check the JSONModel data input."}];
} }
+(id)errorModelIsInvalid +(id)errorModelIsInvalid
......
//
// 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
//
// 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>
//JSONModel transformations // core
#import "JSONModel.h"
#import "JSONModelError.h"
// transformations
#import "JSONValueTransformer.h" #import "JSONValueTransformer.h"
#import "JSONKeyMapper.h" #import "JSONKeyMapper.h"
//basic JSONModel classes // networking (deprecated)
#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;
/** @name Configuring the API */ + (void)getWithPath:(NSString *)path andParams:(NSDictionary *)params completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE;
/** + (void)postWithPath:(NSString *)path andParams:(NSDictionary *)params completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE;
* Sets the API url + (void)rpcWithMethodName:(NSString *)method andArguments:(NSArray *)args completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE;
* @param base the API url as a string + (void)rpc2WithMethodName:(NSString *)method andParams:(id)params completion:(JSONObjectBlock)completeBlock DEPRECATED_ATTRIBUTE;
*/
+(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
//
// 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 "JSONAPI.h" #import "JSONAPI.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wdeprecated-implementations"
#pragma mark - helper error model class #pragma mark - helper error model class
@interface JSONAPIRPCErrorModel: JSONModel @interface JSONAPIRPCErrorModel: JSONModel
@property (assign, nonatomic) int code; @property (assign, nonatomic) int code;
...@@ -26,6 +18,7 @@ ...@@ -26,6 +18,7 @@
#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
...@@ -64,7 +57,7 @@ static long jsonRpcId = 0; ...@@ -64,7 +57,7 @@ static long jsonRpcId = 0;
+(void)getWithPath:(NSString*)path andParams:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock +(void)getWithPath:(NSString*)path andParams:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock
{ {
NSString* fullURL = [NSString stringWithFormat:@"%@%@", sharedInstance.baseURLString, path]; NSString* fullURL = [NSString stringWithFormat:@"%@%@", sharedInstance.baseURLString, path];
[JSONHTTPClient getJSONFromURLWithString: fullURL params:params completion:^(NSDictionary *json, JSONModelError *e) { [JSONHTTPClient getJSONFromURLWithString: fullURL params:params completion:^(NSDictionary *json, JSONModelError *e) {
completeBlock(json, e); completeBlock(json, e);
}]; }];
...@@ -74,7 +67,7 @@ static long jsonRpcId = 0; ...@@ -74,7 +67,7 @@ static long jsonRpcId = 0;
+(void)postWithPath:(NSString*)path andParams:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock +(void)postWithPath:(NSString*)path andParams:(NSDictionary*)params completion:(JSONObjectBlock)completeBlock
{ {
NSString* fullURL = [NSString stringWithFormat:@"%@%@", sharedInstance.baseURLString, path]; NSString* fullURL = [NSString stringWithFormat:@"%@%@", sharedInstance.baseURLString, path];
[JSONHTTPClient postJSONFromURLWithString: fullURL params:params completion:^(NSDictionary *json, JSONModelError *e) { [JSONHTTPClient postJSONFromURLWithString: fullURL params:params completion:^(NSDictionary *json, JSONModelError *e) {
completeBlock(json, e); completeBlock(json, e);
}]; }];
...@@ -83,7 +76,7 @@ static long jsonRpcId = 0; ...@@ -83,7 +76,7 @@ static long jsonRpcId = 0;
#pragma mark - RPC methods #pragma mark - RPC methods
+(void)__rpcRequestWithObject:(id)jsonObject completion:(JSONObjectBlock)completeBlock +(void)__rpcRequestWithObject:(id)jsonObject completion:(JSONObjectBlock)completeBlock
{ {
NSData* jsonRequestData = [NSJSONSerialization dataWithJSONObject:jsonObject NSData* jsonRequestData = [NSJSONSerialization dataWithJSONObject:jsonObject
options:kNilOptions options:kNilOptions
error:nil]; error:nil];
...@@ -111,7 +104,7 @@ static long jsonRpcId = 0; ...@@ -111,7 +104,7 @@ static long jsonRpcId = 0;
e = [JSONModelError errorBadResponse]; e = [JSONModelError errorBadResponse];
} }
} }
//invoke the callback //invoke the callback
completeBlock(result, e); completeBlock(result, e);
} }
...@@ -122,7 +115,7 @@ static long jsonRpcId = 0; ...@@ -122,7 +115,7 @@ static long jsonRpcId = 0;
{ {
NSAssert(method, @"No method specified"); NSAssert(method, @"No method specified");
if (!args) args = @[]; if (!args) args = @[];
[self __rpcRequestWithObject:@{ [self __rpcRequestWithObject:@{
//rpc 1.0 //rpc 1.0
@"id": @(++jsonRpcId), @"id": @(++jsonRpcId),
...@@ -135,7 +128,7 @@ static long jsonRpcId = 0; ...@@ -135,7 +128,7 @@ static long jsonRpcId = 0;
{ {
NSAssert(method, @"No method specified"); NSAssert(method, @"No method specified");
if (!params) params = @[]; if (!params) params = @[];
[self __rpcRequestWithObject:@{ [self __rpcRequestWithObject:@{
//rpc 2.0 //rpc 2.0
@"jsonrpc": @"2.0", @"jsonrpc": @"2.0",
......
// //
// 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" #import "JSONHTTPClient.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#pragma GCC diagnostic ignored "-Wdeprecated-implementations"
typedef void (^RequestResultBlock)(NSData *data, JSONModelError *error); typedef void (^RequestResultBlock)(NSData *data, JSONModelError *error);
#pragma mark - constants #pragma mark - constants
...@@ -97,7 +89,7 @@ static NSString* requestContentType = nil; ...@@ -97,7 +89,7 @@ static NSString* requestContentType = nil;
[requestString substringToIndex:1], [requestString substringToIndex:1],
[requestString substringFromIndex: requestString.length -1] [requestString substringFromIndex: requestString.length -1]
]; ];
if ([firstAndLastChar isEqualToString:@"{}"] || [firstAndLastChar isEqualToString:@"[]"]) { if ([firstAndLastChar isEqualToString:@"{}"] || [firstAndLastChar isEqualToString:@"[]"]) {
//guessing for a JSON request //guessing for a JSON request
contentType = kContentTypeJSON; contentType = kContentTypeJSON;
...@@ -118,7 +110,7 @@ static NSString* requestContentType = nil; ...@@ -118,7 +110,7 @@ static NSString* requestContentType = nil;
if ([value isKindOfClass:[NSNumber class]]) { if ([value isKindOfClass:[NSNumber class]]) {
value = [(NSNumber*)value stringValue]; value = [(NSNumber*)value stringValue];
} }
NSAssert([value isKindOfClass:[NSString class]], @"request parameters can be only of NSString or NSNumber classes. '%@' is of class %@.", value, [value class]); NSAssert([value isKindOfClass:[NSString class]], @"request parameters can be only of NSString or NSNumber classes. '%@' is of class %@.", value, [value class]);
NSString *str = (NSString *)value; NSString *str = (NSString *)value;
...@@ -142,7 +134,7 @@ static NSString* requestContentType = nil; ...@@ -142,7 +134,7 @@ static NSString* requestContentType = nil;
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: url NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: url
cachePolicy: defaultCachePolicy cachePolicy: defaultCachePolicy
timeoutInterval: defaultTimeoutInSeconds]; timeoutInterval: defaultTimeoutInSeconds];
[request setHTTPMethod:method]; [request setHTTPMethod:method];
if ([requestContentType isEqualToString:kContentTypeAutomatic]) { if ([requestContentType isEqualToString:kContentTypeAutomatic]) {
//automatic content type //automatic content type
...@@ -154,17 +146,17 @@ static NSString* requestContentType = nil; ...@@ -154,17 +146,17 @@ static NSString* requestContentType = nil;
//user set content type //user set content type
[request setValue: requestContentType forHTTPHeaderField:@"Content-type"]; [request setValue: requestContentType forHTTPHeaderField:@"Content-type"];
} }
//add all the custom headers defined //add all the custom headers defined
for (NSString* key in [requestHeaders allKeys]) { for (NSString* key in [requestHeaders allKeys]) {
[request setValue:requestHeaders[key] forHTTPHeaderField:key]; [request setValue:requestHeaders[key] forHTTPHeaderField:key];
} }
//add the custom headers //add the custom headers
for (NSString* key in [headers allKeys]) { for (NSString* key in [headers allKeys]) {
[request setValue:headers[key] forHTTPHeaderField:key]; [request setValue:headers[key] forHTTPHeaderField:key];
} }
if (bodyData) { if (bodyData) {
[request setHTTPBody: bodyData]; [request setHTTPBody: bodyData];
[request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)bodyData.length] forHTTPHeaderField:@"Content-Length"]; [request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)bodyData.length] forHTTPHeaderField:@"Content-Length"];
...@@ -198,7 +190,7 @@ static NSString* requestContentType = nil; ...@@ -198,7 +190,7 @@ static NSString* requestContentType = nil;
if (!data.length) { if (!data.length) {
data = nil; data = nil;
} }
handler(data, error); handler(data, error);
}; };
...@@ -231,7 +223,7 @@ static NSString* requestContentType = nil; ...@@ -231,7 +223,7 @@ static NSString* requestContentType = nil;
paramsString = [[NSMutableString alloc] initWithString: [paramsString substringToIndex: paramsString.length-1]]; paramsString = [[NSMutableString alloc] initWithString: [paramsString substringToIndex: paramsString.length-1]];
} }
} }
//set the request params //set the request params
if ([method isEqualToString:kHTTPMethodGET] && params) { if ([method isEqualToString:kHTTPMethodGET] && params) {
...@@ -242,7 +234,7 @@ static NSString* requestContentType = nil; ...@@ -242,7 +234,7 @@ static NSString* requestContentType = nil;
paramsString paramsString
]]; ]];
} }
//call the more general synq request method //call the more general synq request method
[self requestDataFromURL: url [self requestDataFromURL: url
method: method method: method
...@@ -285,13 +277,13 @@ static NSString* requestContentType = nil; ...@@ -285,13 +277,13 @@ static NSString* requestContentType = nil;
//step 4: if there's a response at this and no errors, convert to object //step 4: if there's a response at this and no errors, convert to object
if (error==nil) { if (error==nil) {
// Note: it is possible to have a valid response with empty response data (204 No Content). // Note: it is possible to have a valid response with empty response data (204 No Content).
// So only create the JSON object if there is some response data. // So only create the JSON object if there is some response data.
if(responseData.length > 0) if(responseData.length > 0)
{ {
//convert to an object //convert to an object
jsonObject = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; jsonObject = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
} }
} }
//step 4.5: cover an edge case in which meaningful content is return along an error HTTP status code //step 4.5: cover an edge case in which meaningful content is return along an error HTTP status code
else if (error && responseData && jsonObject==nil) { else if (error && responseData && jsonObject==nil) {
...@@ -300,7 +292,7 @@ static NSString* requestContentType = nil; ...@@ -300,7 +292,7 @@ static NSString* requestContentType = nil;
//keep responseData just in case it contains error information //keep responseData just in case it contains error information
error.responseData = responseData; error.responseData = responseData;
} }
//step 5: invoke the complete block //step 5: invoke the complete block
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (completeBlock) { if (completeBlock) {
......
// //
// 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); typedef void (^JSONModelBlock)(id model, JSONModelError *err) DEPRECATED_ATTRIBUTE;
/**
* 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)
...@@ -37,25 +29,25 @@ BOOL _isLoading; ...@@ -37,25 +29,25 @@ BOOL _isLoading;
{ {
id placeholder = [super init]; id placeholder = [super init];
__block id blockSelf = self; __block id blockSelf = self;
if (placeholder) { if (placeholder) {
//initialization //initialization
self.isLoading = YES; self.isLoading = YES;
[JSONHTTPClient getJSONFromURLWithString:urlString [JSONHTTPClient getJSONFromURLWithString:urlString
completion:^(NSDictionary *json, JSONModelError* e) { completion:^(NSDictionary *json, JSONModelError* e) {
JSONModelError* initError = nil; JSONModelError* initError = nil;
blockSelf = [self initWithDictionary:json error:&initError]; blockSelf = [self initWithDictionary:json error:&initError];
if (completeBlock) { if (completeBlock) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
completeBlock(blockSelf, e?e:initError ); completeBlock(blockSelf, e?e:initError );
}); });
} }
self.isLoading = NO; self.isLoading = NO;
}]; }];
} }
return placeholder; return placeholder;
...@@ -63,47 +55,47 @@ BOOL _isLoading; ...@@ -63,47 +55,47 @@ BOOL _isLoading;
+ (void)getModelFromURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock + (void)getModelFromURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock
{ {
[JSONHTTPClient getJSONFromURLWithString:urlString [JSONHTTPClient getJSONFromURLWithString:urlString
completion:^(NSDictionary* jsonDict, JSONModelError* err) completion:^(NSDictionary* jsonDict, JSONModelError* err)
{ {
JSONModel* model = nil; JSONModel* model = nil;
if(err == nil) if(err == nil)
{ {
model = [[self alloc] initWithDictionary:jsonDict error:&err]; model = [[self alloc] initWithDictionary:jsonDict error:&err];
} }
if(completeBlock != nil) if(completeBlock != nil)
{ {
dispatch_async(dispatch_get_main_queue(), ^ dispatch_async(dispatch_get_main_queue(), ^
{ {
completeBlock(model, err); completeBlock(model, err);
}); });
} }
}]; }];
} }
+ (void)postModel:(JSONModel*)post toURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock + (void)postModel:(JSONModel*)post toURLWithString:(NSString*)urlString completion:(JSONModelBlock)completeBlock
{ {
[JSONHTTPClient postJSONFromURLWithString:urlString [JSONHTTPClient postJSONFromURLWithString:urlString
bodyString:[post toJSONString] bodyString:[post toJSONString]
completion:^(NSDictionary* jsonDict, JSONModelError* err) completion:^(NSDictionary* jsonDict, JSONModelError* err)
{ {
JSONModel* model = nil; JSONModel* model = nil;
if(err == nil) if(err == nil)
{ {
model = [[self alloc] initWithDictionary:jsonDict error:&err]; model = [[self alloc] initWithDictionary:jsonDict error:&err];
} }
if(completeBlock != nil) if(completeBlock != nil)
{ {
dispatch_async(dispatch_get_main_queue(), ^ dispatch_async(dispatch_get_main_queue(), ^
{ {
completeBlock(model, err); completeBlock(model, err);
}); });
} }
}]; }];
} }
@end @end
// //
// 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
* to have different property names than the JSON feed keys, look below on how to * to have different property names than the JSON feed keys, look below on how to
* make your model use a key mapper. * make your model use a key mapper.
* *
* For example if you consume JSON from twitter * For example if you consume JSON from twitter
...@@ -31,72 +20,77 @@ typedef NSString* (^JSONModelKeyMapBlock)(NSString* keyName); ...@@ -31,72 +20,77 @@ 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
/** @name Name converters */ // deprecated
/** Block, which takes in a JSON key and converts it to the corresponding property name */ @property (readonly, nonatomic) JSONModelKeyMapBlock JSONToModelKeyBlock DEPRECATED_ATTRIBUTE;
@property (readonly, nonatomic) JSONModelKeyMapBlock JSONToModelKeyBlock; - (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 */
/** 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
* @param importing YES invokes JSONToModelKeyBlock, NO - modelToJSONKeyBlock * @return JSONKeyMapper instance
* @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 two blocks you provide this initializer. * Creates a JSONKeyMapper instance, based on the block you provide this initializer.
* The two parameters take in a JSONModelKeyMapBlock block: * The parameter takes 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)initWithJSONToModelBlock:(JSONModelKeyMapBlock)toModel - (instancetype)initWithModelToJSONBlock:(JSONModelKeyMapBlock)toJSON;
modelToJSONBlock:(JSONModelKeyMapBlock)toJSON;
/** /**
* Creates a JSONKeyMapper instance, based on the mapping you provide * Creates a JSONKeyMapper instance, based on the mapping you provide.
* in the map parameter. Use the JSON key names as keys, your JSONModel * Use your JSONModel property names as keys, and the JSON key names as values.
* property names as values. * @param toJSON map dictionary, in the format: <pre>@{@"myCamelCaseName":@"crazy_JSON_name"}</pre>
* @param map map dictionary, in the format: <pre>@{@"crazy_JSON_name":@"myCamelCaseName"}</pre>
* @return JSONKeyMapper instance * @return JSONKeyMapper instance
*/ */
-(instancetype)initWithDictionary:(NSDictionary*)map; - (instancetype)initWithModelToJSONDictionary:(NSDictionary *)toJSON;
/** /**
* Creates a JSONKeyMapper, which converts underscore_case to camelCase and vice versa. * Given a camelCase model property, this mapper finds JSON keys using the snake_case equivalent.
*/ */
+(instancetype)mapperFromUnderscoreCaseToCamelCase; + (instancetype)mapperForSnakeCase;
+(instancetype)mapperFromUpperCaseToLowerCase; /**
* Given a camelCase model property, this mapper finds JSON keys using the TitleCase equivalent.
*/
+ (instancetype)mapperForTitleCase;
/** /**
* 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 the original JSON key names as keys, and your JSONModel property names as values. * Use your JSONModel property names as keys, and the JSON key names as values.
*/ */
+ (instancetype)mapper:(JSONKeyMapper *)baseKeyMapper withExceptions:(NSDictionary *)exceptions; + (instancetype)baseMapper:(JSONKeyMapper *)baseKeyMapper withModelToJSONExceptions:(NSDictionary *)toJSON;
@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"
///////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////
...@@ -30,7 +18,7 @@ extern BOOL isNull(id value); ...@@ -30,7 +18,7 @@ extern BOOL isNull(id value);
#pragma mark - JSONValueTransformer interface #pragma mark - JSONValueTransformer interface
/** /**
* **You don't need to call methods of this class manually.** * **You don't need to call methods of this class manually.**
* *
* Class providing methods to transform values from one class to another. * Class providing methods to transform values from one class to another.
* You are given a number of built-in transformers, but you are encouraged to * You are given a number of built-in transformers, but you are encouraged to
...@@ -44,7 +32,7 @@ extern BOOL isNull(id value); ...@@ -44,7 +32,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 */
/** /**
...@@ -54,7 +42,7 @@ extern BOOL isNull(id value); ...@@ -54,7 +42,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 */
...@@ -63,7 +51,7 @@ extern BOOL isNull(id value); ...@@ -63,7 +51,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
/** /**
...@@ -71,16 +59,7 @@ extern BOOL isNull(id value); ...@@ -71,16 +59,7 @@ 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
/** /**
...@@ -88,7 +67,7 @@ extern BOOL isNull(id value); ...@@ -88,7 +67,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 */
...@@ -97,28 +76,28 @@ extern BOOL isNull(id value); ...@@ -97,28 +76,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 */
...@@ -127,21 +106,21 @@ extern BOOL isNull(id value); ...@@ -127,21 +106,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
/** /**
...@@ -149,28 +128,28 @@ extern BOOL isNull(id value); ...@@ -149,28 +128,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
...@@ -180,14 +159,14 @@ extern BOOL isNull(id value); ...@@ -180,14 +159,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
...@@ -197,7 +176,7 @@ extern BOOL isNull(id value); ...@@ -197,7 +176,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
...@@ -209,14 +188,14 @@ extern BOOL isNull(id value); ...@@ -209,14 +188,14 @@ extern BOOL isNull(id value);
#pragma mark - string <-> date #pragma mark - string <-> date
/** @name Transforming Dates */ /** @name Transforming Dates */
/** /**
* The following two methods are not public. This way if there is a category on converting * The following two methods are not public. This way if there is a category on converting
* dates it'll override them. If there isn't a category the default methods found in the .m * dates it'll override them. If there isn't a category the default methods found in the .m
* file will be invoked. If these are public a warning is produced at the point of overriding * file will be invoked. If these are public a warning is produced at the point of overriding
* 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
...@@ -225,6 +204,6 @@ extern BOOL isNull(id value); ...@@ -225,6 +204,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)
{ {
if (!value) return YES; if (!value) return YES;
if ([value isKindOfClass:[NSNull class]]) return YES; if ([value isKindOfClass:[NSNull class]]) return YES;
return NO; return NO;
} }
...@@ -36,7 +24,7 @@ extern BOOL isNull(id value) ...@@ -36,7 +24,7 @@ extern BOOL isNull(id value)
//and some famous aliases of primitive types //and some famous aliases of primitive types
// BOOL is now "B" on iOS __LP64 builds // BOOL is now "B" on iOS __LP64 builds
@"I":@"NSInteger", @"Q":@"NSUInteger", @"B":@"BOOL", @"I":@"NSInteger", @"Q":@"NSUInteger", @"B":@"BOOL",
@"@?":@"Block"}; @"@?":@"Block"};
} }
return self; return self;
...@@ -48,7 +36,7 @@ extern BOOL isNull(id value) ...@@ -48,7 +36,7 @@ extern BOOL isNull(id value)
if ([sourceClass isSubclassOfClass:[NSString class]]) { if ([sourceClass isSubclassOfClass:[NSString class]]) {
return [NSString class]; return [NSString class];
} }
//check for all variations of numbers //check for all variations of numbers
if ([sourceClass isSubclassOfClass:[NSNumber class]]) { if ([sourceClass isSubclassOfClass:[NSNumber class]]) {
return [NSNumber class]; return [NSNumber class];
...@@ -58,7 +46,7 @@ extern BOOL isNull(id value) ...@@ -58,7 +46,7 @@ extern BOOL isNull(id value)
if ([sourceClass isSubclassOfClass:[NSArray class]]) { if ([sourceClass isSubclassOfClass:[NSArray class]]) {
return [NSArray class]; return [NSArray class];
} }
//check for all variations of arrays //check for all variations of arrays
if ([sourceClass isSubclassOfClass:[NSDictionary class]]) { if ([sourceClass isSubclassOfClass:[NSDictionary class]]) {
return [NSDictionary class]; return [NSDictionary class];
...@@ -82,26 +70,9 @@ extern BOOL isNull(id value) ...@@ -82,26 +70,9 @@ 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
{ {
...@@ -142,7 +113,7 @@ extern BOOL isNull(id value) ...@@ -142,7 +113,7 @@ extern BOOL isNull(id value)
-(NSNumber*)BOOLFromNSString:(NSString*)string -(NSNumber*)BOOLFromNSString:(NSString*)string
{ {
if (string != nil && if (string != nil &&
([string caseInsensitiveCompare:@"true"] == NSOrderedSame || ([string caseInsensitiveCompare:@"true"] == NSOrderedSame ||
[string caseInsensitiveCompare:@"yes"] == NSOrderedSame)) { [string caseInsensitiveCompare:@"yes"] == NSOrderedSame)) {
return [NSNumber numberWithBool:YES]; return [NSNumber numberWithBool:YES];
...@@ -179,7 +150,7 @@ extern BOOL isNull(id value) ...@@ -179,7 +150,7 @@ extern BOOL isNull(id value)
#pragma mark - string <-> number #pragma mark - string <-> number
-(NSNumber*)NSNumberFromNSString:(NSString*)string -(NSNumber*)NSNumberFromNSString:(NSString*)string
{ {
return [NSNumber numberWithFloat: [string doubleValue]]; return [NSNumber numberWithDouble:[string doubleValue]];
} }
-(NSString*)NSStringFromNSNumber:(NSNumber*)number -(NSString*)NSStringFromNSNumber:(NSNumber*)number
...@@ -201,7 +172,7 @@ extern BOOL isNull(id value) ...@@ -201,7 +172,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/icanzilb/JSONModel/pull/119 // see: https://github.com/jsonmodel/jsonmodel/pull/119
return [NSURL URLWithString:string]; return [NSURL URLWithString:string];
} }
...@@ -232,7 +203,7 @@ extern BOOL isNull(id value) ...@@ -232,7 +203,7 @@ extern BOOL isNull(id value)
-(NSString*)__JSONObjectFromNSDate:(NSDate*)date -(NSString*)__JSONObjectFromNSDate:(NSDate*)date
{ {
static dispatch_once_t onceOutput; static dispatch_once_t onceOutput;
static NSDateFormatter *outputDateFormatter; static NSDateFormatter *outputDateFormatter;
dispatch_once(&onceOutput, ^{ dispatch_once(&onceOutput, ^{
outputDateFormatter = [[NSDateFormatter alloc] init]; outputDateFormatter = [[NSDateFormatter alloc] init];
[outputDateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; [outputDateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
...@@ -258,7 +229,7 @@ extern BOOL isNull(id value) ...@@ -258,7 +229,7 @@ extern BOOL isNull(id value)
} }
#pragma mark - hidden transform for empty dictionaries #pragma mark - hidden transform for empty dictionaries
//https://github.com/icanzilb/JSONModel/issues/163 //https://github.com/jsonmodel/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.
...@@ -32,7 +32,7 @@ PODS: ...@@ -32,7 +32,7 @@ PODS:
- FMDB/standard (2.6.2) - FMDB/standard (2.6.2)
- IQKeyboardManager (3.2.4) - IQKeyboardManager (3.2.4)
- JPushSDK (1.8.2) - JPushSDK (1.8.2)
- JSONModel (1.2.0) - JSONModel (1.7.0)
- Masonry (1.0.1) - Masonry (1.0.1)
- MBProgressHUD (0.9.2) - MBProgressHUD (0.9.2)
- MJRefresh (3.1.3) - MJRefresh (3.1.3)
...@@ -57,7 +57,7 @@ DEPENDENCIES: ...@@ -57,7 +57,7 @@ DEPENDENCIES:
- FMDB (~> 2.5) - FMDB (~> 2.5)
- IQKeyboardManager (~> 3.2.3) - IQKeyboardManager (~> 3.2.3)
- JPushSDK (~> 1.8.2) - JPushSDK (~> 1.8.2)
- JSONModel (~> 1.2.0) - JSONModel (~> 1.7.0)
- Masonry (~> 1.0.1) - Masonry (~> 1.0.1)
- MBProgressHUD (~> 0.9.1) - MBProgressHUD (~> 0.9.1)
- MJRefresh (~> 3.1.0) - MJRefresh (~> 3.1.0)
...@@ -76,7 +76,7 @@ SPEC CHECKSUMS: ...@@ -76,7 +76,7 @@ SPEC CHECKSUMS:
FMDB: 854a0341b4726e53276f2a8996f06f1b80f9259a FMDB: 854a0341b4726e53276f2a8996f06f1b80f9259a
IQKeyboardManager: 555b1231fefafb21b19278d7cca72986a27b748b IQKeyboardManager: 555b1231fefafb21b19278d7cca72986a27b748b
JPushSDK: c68dd04c595a5c93aa003f212974010790410d8e JPushSDK: c68dd04c595a5c93aa003f212974010790410d8e
JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c JSONModel: 840bc0fcffb24b8454d2c026bf26fea454b8e98d
Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df
MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1 MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1
MJRefresh: e9005c294dd8a3d08cc7c50eea2b5016673f29c4 MJRefresh: e9005c294dd8a3d08cc7c50eea2b5016673f29c4
......
This diff is collapsed.
...@@ -132,29 +132,24 @@ LICENSE Copyright 2010 - 2014 JPush.cn, Inc. All rights reserved. ...@@ -132,29 +132,24 @@ LICENSE Copyright 2010 - 2014 JPush.cn, Inc. All rights reserved.
## JSONModel ## JSONModel
JSONModel Copyright (c) 2012-2016 Marin Todorov and JSONModel contributors
Copyright (c) 2012-2014 Marin Todorov, Underplot ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of
This code is distributed under the terms and conditions of the MIT license. this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
Permission is hereby granted, free of charge, to any person obtaining a copy of use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
this software and associated documentation files (the "Software"), to deal in the the Software, and to permit persons to whom the Software is furnished to do so,
Software without restriction, including without limitation the rights to use, copy, subject to the following conditions:
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 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 IMPLIED, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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
## MBProgressHUD ## MBProgressHUD
......
...@@ -171,29 +171,24 @@ SOFTWARE. ...@@ -171,29 +171,24 @@ SOFTWARE.
</dict> </dict>
<dict> <dict>
<key>FooterText</key> <key>FooterText</key>
<string>JSONModel <string>Copyright (c) 2012-2016 Marin Todorov and JSONModel contributors
Copyright (c) 2012-2014 Marin Todorov, Underplot ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of
This code is distributed under the terms and conditions of the MIT license. this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
Permission is hereby granted, free of charge, to any person obtaining a copy of use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
this software and associated documentation files (the "Software"), to deal in the the Software, and to permit persons to whom the Software is furnished to do so,
Software without restriction, including without limitation the rights to use, copy, subject to the following conditions:
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 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 IMPLIED, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 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
</string> </string>
<key>Title</key> <key>Title</key>
<string>JSONModel</string> <string>JSONModel</string>
......
...@@ -15,5 +15,5 @@ pod 'JPushSDK', '~> 1.8.2' ...@@ -15,5 +15,5 @@ pod 'JPushSDK', '~> 1.8.2'
pod 'RETableViewManager', '~> 1.6' pod 'RETableViewManager', '~> 1.6'
pod 'YLProgressBar', '~> 3.8.1' pod 'YLProgressBar', '~> 3.8.1'
pod 'WYPopoverController', '~> 0.3.9' pod 'WYPopoverController', '~> 0.3.9'
pod 'JSONModel', '~> 1.2.0' pod 'JSONModel', '~> 1.7.0'
pod 'DZNEmptyDataSet', '~> 1.8.1' pod 'DZNEmptyDataSet', '~> 1.8.1'
...@@ -3123,8 +3123,8 @@ ...@@ -3123,8 +3123,8 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = 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";
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
...@@ -3140,7 +3140,7 @@ ...@@ -3140,7 +3140,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.gomoe.total; PRODUCT_BUNDLE_IDENTIFIER = com.gomoe.total;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "f96494cb-c220-43ce-8034-75e000c2193f";
SWIFT_OBJC_BRIDGING_HEADER = "total/total-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "total/total-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
...@@ -3171,7 +3171,7 @@ ...@@ -3171,7 +3171,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.gomoe.total; PRODUCT_BUNDLE_IDENTIFIER = com.gomoe.total;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = ""; PROVISIONING_PROFILE = "f96494cb-c220-43ce-8034-75e000c2193f";
SWIFT_OBJC_BRIDGING_HEADER = "total/total-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "total/total-Bridging-Header.h";
TARGETED_DEVICE_FAMILY = 1; TARGETED_DEVICE_FAMILY = 1;
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**"; USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
......
...@@ -326,8 +326,6 @@ ...@@ -326,8 +326,6 @@
stateStr = GTO_LICENCE__STATE_APPROVED; stateStr = GTO_LICENCE__STATE_APPROVED;
}else if(indexPath.row == 7){ }else if(indexPath.row == 7){
stateStr =GTO_LICENCE__STATE_FINISHED; stateStr =GTO_LICENCE__STATE_FINISHED;
}else {
} }
[self.delegate getBoltValueSelectRow:stateStr]; [self.delegate getBoltValueSelectRow:stateStr];
} }
......
...@@ -79,8 +79,8 @@ ...@@ -79,8 +79,8 @@
//#define HTTP_LOCAL_BASE_URL @"http://218.244.151.129:7580" //#define HTTP_LOCAL_BASE_URL @"http://218.244.151.129:7580"
////正式环境 ////正式环境
//#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:7080/total-server/rest" #define HTTP_REST_API_BASE_URL @"http://139.196.39.77:7080/total-server/rest"
//#define HTTP_LOCAL_BASE_URL @"http://139.196.39.77:7080" #define HTTP_LOCAL_BASE_URL @"http://139.196.39.77:7080"
// //
//测试环境 //测试环境
//#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:8180/total-server/rest" //#define HTTP_REST_API_BASE_URL @"http://139.196.39.77:8180/total-server/rest"
...@@ -96,8 +96,6 @@ ...@@ -96,8 +96,6 @@
#define HTTP_WEATHER_URL @"http://apis.baidu.com/heweather/weather/free" #define HTTP_WEATHER_URL @"http://apis.baidu.com/heweather/weather/free"
//refreshUpdateDate //refreshUpdateDate
#define PurchaseNoticeUpdateDate @"purchaseNoticeUpdateDate" #define PurchaseNoticeUpdateDate @"purchaseNoticeUpdateDate"
#define TemplateNameUpdateDate @"templateNameUpdateDate" #define TemplateNameUpdateDate @"templateNameUpdateDate"
......
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