MapsIndoors iOS SDK  V3
List of all members
MPJSONValueTransformer Class Reference

#import <MPJSONValueTransformer.h>

Inherits NSObject.

Instance Methods

Transforming to Mutable copies
(NSMutableString *) - NSMutableStringFromNSString:
 
(NSMutableArray *) - NSMutableArrayFromNSArray:
 
(NSMutableDictionary *) - NSMutableDictionaryFromNSDictionary:
 
Transforming Sets
(NSSet *) - NSSetFromNSArray:
 
(NSMutableSet *) - NSMutableSetFromNSArray:
 
(NSArray *) - JSONObjectFromNSSet:
 
(NSArray *) - JSONObjectFromNSMutableSet:
 
Transforming JSON types
(NSNumber *) - BOOLFromNSNumber:
 
(NSNumber *) - BOOLFromNSString:
 
(NSNumber *) - JSONObjectFromBOOL:
 
(NSNumber *) - NSNumberFromNSString:
 
(NSString *) - NSStringFromNSNumber:
 
(NSDecimalNumber *) - NSDecimalNumberFromNSString:
 
(NSString *) - NSStringFromNSDecimalNumber:
 
Transforming URLs
(NSURL *) - NSURLFromNSString:
 
(NSString *) - JSONObjectFromNSURL:
 
Transforming NSTimeZone
(NSTimeZone *) - NSTimeZoneFromNSString:
 
(NSString *) - JSONObjectFromNSTimeZone:
 
Transforming Dates
(NSDate *) - NSDateFromNSNumber:
 

Class Methods

Resolving cluster class names
(Class) + classByResolvingClusterClasses:
 

Detailed Description

You don't need to call methods of this class manually.

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 extend this class with your own categories to add further value transformers. Just few examples of what can you add to MPJSONValueTransformer: hex colors in JSON to UIColor, hex numbers in JSON to NSNumber model properties, base64 encoded strings in JSON to UIImage properties, and more.

The class is invoked by MPJSONModel while transforming incoming JSON types into your target class property classes, and vice versa. One static copy is create and store in the MPJSONModel class scope.

Method Documentation

◆ BOOLFromNSNumber:

- (NSNumber *) BOOLFromNSNumber: (NSNumber *)  number

Transforms a number object to a bool number object

Parameters
numberthe number to convert
Returns
the resulting number

◆ BOOLFromNSString:

- (NSNumber *) BOOLFromNSString: (NSString *)  string

Transforms a number object to a bool number object

Parameters
stringthe string value to convert, "0" converts to NO, everything else to YES
Returns
the resulting number

◆ classByResolvingClusterClasses:

+ (Class) classByResolvingClusterClasses: (Class)  sourceClass

This method returns the umbrella class for any standard class cluster members. For example returns NSString when given as input NSString, NSMutableString, __CFString and __CFConstantString The method currently looksup a pre-defined list.

Parameters
sourceClassthe class to get the umbrella class for
Returns
Class

◆ JSONObjectFromBOOL:

- (NSNumber *) JSONObjectFromBOOL: (NSNumber *)  number

Transforms a BOOL value to a bool number object

Parameters
numberan NSNumber value coming from the model
Returns
the result number

◆ JSONObjectFromNSMutableSet:

- (NSArray *) JSONObjectFromNSMutableSet: (NSMutableSet *)  set

Transforms a mutable set to an array

Parameters
setincoming mutable set
Returns
an array with the set's elements

◆ JSONObjectFromNSSet:

- (NSArray *) JSONObjectFromNSSet: (NSSet *)  set

Transforms a set to an array

Parameters
setincoming set
Returns
an array with the set's elements

◆ JSONObjectFromNSTimeZone:

- (NSString *) JSONObjectFromNSTimeZone: (NSTimeZone *)  timeZone

Transforms an NSTimeZone object to a string

Parameters
timeZonethe time zone object to convert
Returns
the resulting string

◆ JSONObjectFromNSURL:

- (NSString *) JSONObjectFromNSURL: (NSURL *)  url

Transforms an NSURL object to a string

Parameters
urlthe url object to convert
Returns
the resulting string

◆ NSDateFromNSNumber:

- (NSDate *) NSDateFromNSNumber: (NSNumber *)  number

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 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. Transforms a number to an NSDate object

Parameters
numberthe number to convert
Returns
the resulting date

◆ NSDecimalNumberFromNSString:

- (NSDecimalNumber *) NSDecimalNumberFromNSString: (NSString *)  string

Transforms a string object to a nsdecimalnumber object

Parameters
stringthe string to convert
Returns
the resulting number

◆ NSMutableArrayFromNSArray:

- (NSMutableArray *) NSMutableArrayFromNSArray: (NSArray *)  array

Transforms an array to a mutable array

Parameters
arrayincoming array
Returns
mutable array

◆ NSMutableDictionaryFromNSDictionary:

- (NSMutableDictionary *) NSMutableDictionaryFromNSDictionary: (NSDictionary *)  dict

Transforms a dictionary to a mutable dictionary

Parameters
dictincoming dictionary
Returns
mutable dictionary

◆ NSMutableSetFromNSArray:

- (NSMutableSet *) NSMutableSetFromNSArray: (NSArray *)  array

Transforms an array to a mutable set

Parameters
arrayincoming array
Returns
mutable set with the array's elements

◆ NSMutableStringFromNSString:

- (NSMutableString *) NSMutableStringFromNSString: (NSString *)  string

Transforms a string value to a mutable string value

Parameters
stringincoming string
Returns
mutable string

◆ NSNumberFromNSString:

- (NSNumber *) NSNumberFromNSString: (NSString *)  string

Transforms a string object to a number object

Parameters
stringthe string to convert
Returns
the resulting number

◆ NSSetFromNSArray:

- (NSSet *) NSSetFromNSArray: (NSArray *)  array

Transforms an array to a set

Parameters
arrayincoming array
Returns
set with the array's elements

◆ NSStringFromNSDecimalNumber:

- (NSString *) NSStringFromNSDecimalNumber: (NSDecimalNumber *)  number

Transforms a nsdecimalnumber object to a string object

Parameters
numberthe number to convert
Returns
the resulting string

◆ NSStringFromNSNumber:

- (NSString *) NSStringFromNSNumber: (NSNumber *)  number

Transforms a number object to a string object

Parameters
numberthe number to convert
Returns
the resulting string

◆ NSTimeZoneFromNSString:

- (NSTimeZone *) NSTimeZoneFromNSString: (NSString *)  string

Transforms a string object to an NSTimeZone object

Parameters
stringthe string to convert
Returns
the resulting NSTimeZone object

◆ NSURLFromNSString:

- (NSURL *) NSURLFromNSString: (NSString *)  string

Transforms a string object to an NSURL object

Parameters
stringthe string to convert
Returns
the resulting url object

The documentation for this class was generated from the following file: