@@ -25,160 +25,11 @@ @interface MasterViewController () {
25
25
}
26
26
@end
27
27
28
- /*
29
- #define OPT(type, opt, name) type name; @property id opt name##Property__;
30
- #define OptionalProperties(...) @property BOOL zz_____OptionalPropertiesBegin; __VA_ARGS__ @property BOOL zz_____OptionalPropertiesEnd;
31
-
32
- @interface Ignore_Model : JSONModel
33
-
34
- //OptionalProperties
35
- //(
36
- @property (strong, nonatomic) NSNumber<Optional>* oName;
37
- //)
38
-
39
- @property (assign, nonatomic) OPT(BOOL, <Optional>, name);
40
- @property (strong, nonatomic) NSNumber<Ignore, Optional, Index>* iName;
41
- @property (strong, nonatomic) NSDate* mydate;
42
-
43
- @end
44
-
45
- @implementation Ignore_Model
46
-
47
- //@dynamic nameProperty;
48
-
49
- +(BOOL)propertyIsOptional:(NSString*)propertyName
50
- {
51
- return ([propertyName isEqualToString:@"name"]);
52
- }
53
-
54
- @end
55
-
56
- @interface TopModel : JSONModel
57
- @property (strong, nonatomic) Ignore_Model* im;
58
- @end
59
-
60
- @implementation TopModel
61
- @end
62
- */
63
-
64
- #define modelOptional
65
-
66
- @protocol JSONAnswer
67
-
68
- @end
69
-
70
- //
71
- // JSON Connector
72
- //
73
-
74
- @protocol JSONAnswerJSON
75
-
76
- @required
77
- @property (nonatomic ) NSString * name;
78
-
79
- @optional
80
- @property (nonatomic ) NSString * age;
81
-
82
- -(void )importAgeFromJSON : (id )value ;
83
- -(id )exportAgeToJSON ;
84
-
85
- -(void )importAgeFromCoreData : (id )value ;
86
- -(id )exportAgeToCoreData ;
87
-
88
- @end
89
-
90
- @interface JSONAnswer : JSONModel
91
- @property (nonatomic , modelOptional) NSString * name;
92
- @end
93
-
94
- @implementation JSONAnswer
95
- @end
96
-
97
- @interface TopModel : JSONModel
98
- @property (strong , nonatomic ) NSArray <JSONAnswer>* answers;
99
- @end
100
-
101
- @implementation TopModel
102
- +(BOOL )propertyIsOptional : (NSString *)propertyName {
103
- if ([propertyName isEqualToString: @" answers" ]) {
104
- return YES ;
105
- }
106
- return [super propertyIsOptional: propertyName];
107
- }
108
- @end
109
-
110
28
@implementation MasterViewController
111
29
112
30
-(void )viewDidAppear : (BOOL )animated
113
31
{
114
32
115
-
116
-
117
- /*
118
- Protocol *proto = objc_getProtocol(@"JSONAnswerJSON".UTF8String);
119
- NSLog(@"proto: %@", proto);
120
-
121
- unsigned int propertyCount;
122
- objc_property_t *properties = protocol_copyPropertyList(proto, &propertyCount);
123
-
124
- NSLog(@"%i properties found", propertyCount);
125
-
126
- for (unsigned int i = 0; i < propertyCount; i++) {
127
- //get property name
128
- objc_property_t property = properties[i];
129
- const char *propertyName = property_getName(property);
130
- NSString* name = [NSString stringWithUTF8String:propertyName];
131
-
132
- //JMLog(@"property: %@", p.name);
133
-
134
- //get property attributes
135
- const char *attrs = property_getAttributes(property);
136
- NSString* propertyAttributes = [NSString stringWithUTF8String:attrs];
137
-
138
- NSLog(@"%@ attr: %@", name, propertyAttributes);
139
- }
140
-
141
-
142
- NSString* json = @"{}";
143
- TopModel* mm = [[TopModel alloc] initWithString:json error:nil];
144
- NSLog(@"TopModel: %@", mm);
145
-
146
-
147
- NSString* json = @"{\"im\":{\"name\": \"1\",\"oName\":null, \"mydate\":\"2013-09-20T07:56:16+0200\"}}";
148
- NSError* err = nil;
149
- TopModel* tm = [[TopModel alloc] initWithString:json error: &err];
150
-
151
- if (err) {
152
- NSLog(@"Error: %@", err.localizedDescription);
153
- }
154
-
155
- NSLog(@"tm: %@", tm);
156
- NSLog(@"tm.im: %@", tm.im);
157
- NSLog(@"tm.im.oname: %@", tm.im.oName);
158
- NSLog(@"tm.mydate: %@ %@", [tm.im.mydate class], tm.im.mydate);
159
- */
160
- // [self tableView: self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
161
- /*
162
- [JSONHTTPClient setTimeoutInSeconds:2];
163
- [JSONHTTPClient getJSONFromURLWithString:@"http://localhost/testapi/test.php"
164
- completion:^(NSDictionary *json, JSONModelError *err) {
165
- NSLog(@"success: got json %@", json);
166
- NSLog(@"error: got %@", [err localizedDescription]);
167
- }];
168
-
169
- [JSONCache sharedCache].expirationTimeInHours = kImmediatelyExpire;
170
- [JSONCache sharedCache].expirationTimeInHoursWhenOffline = kNeverExpire;
171
- [JSONCache sharedCache].revalidateCacheViaETagAfterTimeInHours = kAlwaysRevalidate;
172
- [JSONCache sharedCache].revalidateCacheFromServerAfterTimeInHours = kAlwaysRevalidate;
173
-
174
- [[JSONCache sharedCache] loadCacheFromDisc];
175
-
176
- NSLog(@"cache: %@", [JSONCache sharedCache]);
177
-
178
- [JSONHTTPClient setIsUsingJSONCache: YES];
179
-
180
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(actionLoadCall:)];
181
- */
182
33
}
183
34
184
35
-(IBAction )actionLoadCall : (id )sender
0 commit comments