|
@@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
Sample Code:
|
|
Sample Code:
|
|
|
|
|
|
********************** json convertor *********************
|
|
********************** json convertor *********************
|
|
|
|
+ @code
|
|
@interface YYAuthor : NSObject
|
|
@interface YYAuthor : NSObject
|
|
@property (nonatomic, strong) NSString *name;
|
|
@property (nonatomic, strong) NSString *name;
|
|
@property (nonatomic, assign) NSDate *birthday;
|
|
@property (nonatomic, assign) NSDate *birthday;
|
|
@@ -49,8 +50,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
NSString *json = [book yy_modelToJSONString];
|
|
NSString *json = [book yy_modelToJSONString];
|
|
// {"author":{"name":"J.K.Rowling","birthday":"1965-07-31T00:00:00+0000"},"name":"Harry Potter","pages":256}
|
|
// {"author":{"name":"J.K.Rowling","birthday":"1965-07-31T00:00:00+0000"},"name":"Harry Potter","pages":256}
|
|
}
|
|
}
|
|
|
|
+ @endcode
|
|
|
|
|
|
********************** Coding/Copying/hash/equal *********************
|
|
********************** Coding/Copying/hash/equal *********************
|
|
|
|
+ @code
|
|
@interface YYShadow :NSObject <NSCoding, NSCopying>
|
|
@interface YYShadow :NSObject <NSCoding, NSCopying>
|
|
@property (nonatomic, copy) NSString *name;
|
|
@property (nonatomic, copy) NSString *name;
|
|
@property (nonatomic, assign) CGSize size;
|
|
@property (nonatomic, assign) CGSize size;
|
|
@@ -63,6 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
- (NSUInteger)hash { return [self yy_modelHash]; }
|
|
- (NSUInteger)hash { return [self yy_modelHash]; }
|
|
- (BOOL)isEqual:(id)object { return [self yy_modelIsEqual:object]; }
|
|
- (BOOL)isEqual:(id)object { return [self yy_modelIsEqual:object]; }
|
|
@end
|
|
@end
|
|
|
|
+ @endcode
|
|
|
|
|
|
*/
|
|
*/
|
|
@interface NSObject (YYModel)
|
|
@interface NSObject (YYModel)
|
|
@@ -282,6 +286,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
}
|
|
}
|
|
|
|
|
|
model:
|
|
model:
|
|
|
|
+ @code
|
|
@interface YYBook : NSObject
|
|
@interface YYBook : NSObject
|
|
@property NSString *name;
|
|
@property NSString *name;
|
|
@property NSInteger page;
|
|
@property NSInteger page;
|
|
@@ -297,6 +302,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
@"bookID": @[@"id", @"ID", @"book_id"]};
|
|
@"bookID": @[@"id", @"ID", @"book_id"]};
|
|
}
|
|
}
|
|
@end
|
|
@end
|
|
|
|
+ @endcode
|
|
|
|
|
|
@return A custom mapper for properties.
|
|
@return A custom mapper for properties.
|
|
*/
|
|
*/
|
|
@@ -310,6 +316,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
object will be add to the array/set/dictionary.
|
|
object will be add to the array/set/dictionary.
|
|
|
|
|
|
Example:
|
|
Example:
|
|
|
|
+ @code
|
|
@class YYShadow, YYBorder, YYAttachment;
|
|
@class YYShadow, YYBorder, YYAttachment;
|
|
|
|
|
|
@interface YYAttributes
|
|
@interface YYAttributes
|
|
@@ -326,6 +333,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
@"attachments" : @"YYAttachment" };
|
|
@"attachments" : @"YYAttachment" };
|
|
}
|
|
}
|
|
@end
|
|
@end
|
|
|
|
+ @endcode
|
|
|
|
|
|
@return A class mapper.
|
|
@return A class mapper.
|
|
*/
|
|
*/
|
|
@@ -340,6 +348,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
(both singular and containers via `+modelContainerPropertyGenericClass`).
|
|
(both singular and containers via `+modelContainerPropertyGenericClass`).
|
|
|
|
|
|
Example:
|
|
Example:
|
|
|
|
+ @code
|
|
@class YYCircle, YYRectangle, YYLine;
|
|
@class YYCircle, YYRectangle, YYLine;
|
|
|
|
|
|
@implementation YYShape
|
|
@implementation YYShape
|
|
@@ -357,6 +366,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
}
|
|
}
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
+ @endcode
|
|
|
|
|
|
@param dictionary The json/kv dictionary.
|
|
@param dictionary The json/kv dictionary.
|
|
|
|
|