Skip to content

Commit 85d6166

Browse files
committed
Add logAllProperties
You can use the macro MJExtensionLogAllProperties to log all the properties of model.
1 parent 18ba7f6 commit 85d6166

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

MJExtension.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "MJExtension"
3-
s.version = "2.5.5"
3+
s.version = "2.5.6"
44
s.ios.deployment_target = '6.0'
55
s.osx.deployment_target = '10.8'
66
s.summary = "The fastest and most convenient conversion between JSON and model"

MJExtension/MJExtensionConst.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ MJExtensionAssert2((param) != nil, returnValue)
5353
{ \
5454
return [self keyValues].description; \
5555
}
56-
#define MJExtensionLogAllIvars MJLogAllIvars
56+
#define MJExtensionLogAllProperties MJLogAllIvars
5757

5858
/**
5959
* 类型(属性类型)

MJExtensionExample/MJExtensionExample/Classes/User.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ @implementation User
1313
//{
1414
// return @[@"name", @"icon"];
1515
//}
16+
MJExtensionLogAllProperties
1617
@end

MJExtensionExample/MJExtensionExample/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void coreData();
2323
void coding();
2424
void replacedKeyFromPropertyName121();
2525
void newValueFromOldValue();
26+
void logAllProperties();
2627
void execute(void (*fn)(), NSString *comment);
2728

2829
#endif

MJExtensionExample/MJExtensionExample/main.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ int main(int argc, const char * argv[])
5050
execute(coding, @"NSCoding示例");
5151
execute(replacedKeyFromPropertyName121, @"统一转换属性名(比如驼峰转下划线)");
5252
execute(newValueFromOldValue, @"过滤字典的值(比如字符串日期处理为NSDate、字符串nil处理为@""");
53+
execute(logAllProperties, @"使用NSLog打印模型的所有属性");
5354
}
5455
return 0;
5556
}
@@ -409,6 +410,20 @@ void newValueFromOldValue()
409410
NSLog(@"name=%@, publisher=%@, publishedTime=%@", book.name, book.publisher, book.publishedTime);
410411
}
411412

413+
/**
414+
* 使用NSLog打印模型的所有属性
415+
*/
416+
void logAllProperties()
417+
{
418+
User *user = [[User alloc] init];
419+
user.name = @"MJ";
420+
user.age = 10;
421+
user.sex = SexMale;
422+
user.icon = @"test.png";
423+
424+
NSLog(@"%@", user);
425+
}
426+
412427
void execute(void (*fn)(), NSString *comment)
413428
{
414429
NSLog(@"[******************%@******************开始]", comment);

0 commit comments

Comments
 (0)