Skip to content

Commit

Permalink
removed temp code
Browse files Browse the repository at this point in the history
  • Loading branch information
icanzilb committed Jan 21, 2014
1 parent ab3fba9 commit 90cb0ec
Showing 1 changed file with 0 additions and 149 deletions.
149 changes: 0 additions & 149 deletions JSONModelDemo_iOS/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,160 +25,11 @@ @interface MasterViewController () {
}
@end

/*
#define OPT(type, opt, name) type name; @property id opt name##Property__;
#define OptionalProperties(...) @property BOOL zz_____OptionalPropertiesBegin; __VA_ARGS__ @property BOOL zz_____OptionalPropertiesEnd;
@interface Ignore_Model : JSONModel
//OptionalProperties
//(
@property (strong, nonatomic) NSNumber<Optional>* oName;
//)
@property (assign, nonatomic) OPT(BOOL, <Optional>, name);
@property (strong, nonatomic) NSNumber<Ignore, Optional, Index>* iName;
@property (strong, nonatomic) NSDate* mydate;
@end
@implementation Ignore_Model
//@dynamic nameProperty;
+(BOOL)propertyIsOptional:(NSString*)propertyName
{
return ([propertyName isEqualToString:@"name"]);
}
@end
@interface TopModel : JSONModel
@property (strong, nonatomic) Ignore_Model* im;
@end
@implementation TopModel
@end
*/

#define modelOptional

@protocol JSONAnswer

@end

//
// JSON Connector
//

@protocol JSONAnswerJSON

@required
@property (nonatomic) NSString* name;

@optional
@property (nonatomic) NSString* age;

-(void)importAgeFromJSON:(id)value;
-(id)exportAgeToJSON;

-(void)importAgeFromCoreData:(id)value;
-(id)exportAgeToCoreData;

@end

@interface JSONAnswer : JSONModel
@property (nonatomic, modelOptional) NSString* name;
@end

@implementation JSONAnswer
@end

@interface TopModel : JSONModel
@property (strong, nonatomic) NSArray<JSONAnswer>* answers;
@end

@implementation TopModel
+(BOOL)propertyIsOptional:(NSString*)propertyName {
if ([propertyName isEqualToString:@"answers"]) {
return YES;
}
return [super propertyIsOptional:propertyName];
}
@end

@implementation MasterViewController

-(void)viewDidAppear:(BOOL)animated
{



/*
Protocol *proto = objc_getProtocol(@"JSONAnswerJSON".UTF8String);
NSLog(@"proto: %@", proto);
unsigned int propertyCount;
objc_property_t *properties = protocol_copyPropertyList(proto, &propertyCount);
NSLog(@"%i properties found", propertyCount);
for (unsigned int i = 0; i < propertyCount; i++) {
//get property name
objc_property_t property = properties[i];
const char *propertyName = property_getName(property);
NSString* name = [NSString stringWithUTF8String:propertyName];
//JMLog(@"property: %@", p.name);
//get property attributes
const char *attrs = property_getAttributes(property);
NSString* propertyAttributes = [NSString stringWithUTF8String:attrs];
NSLog(@"%@ attr: %@", name, propertyAttributes);
}
NSString* json = @"{}";
TopModel* mm = [[TopModel alloc] initWithString:json error:nil];
NSLog(@"TopModel: %@", mm);
NSString* json = @"{\"im\":{\"name\": \"1\",\"oName\":null, \"mydate\":\"2013-09-20T07:56:16+0200\"}}";
NSError* err = nil;
TopModel* tm = [[TopModel alloc] initWithString:json error: &err];
if (err) {
NSLog(@"Error: %@", err.localizedDescription);
}
NSLog(@"tm: %@", tm);
NSLog(@"tm.im: %@", tm.im);
NSLog(@"tm.im.oname: %@", tm.im.oName);
NSLog(@"tm.mydate: %@ %@", [tm.im.mydate class], tm.im.mydate);
*/
//[self tableView: self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
/*
[JSONHTTPClient setTimeoutInSeconds:2];
[JSONHTTPClient getJSONFromURLWithString:@"http://localhost/testapi/test.php"
completion:^(NSDictionary *json, JSONModelError *err) {
NSLog(@"success: got json %@", json);
NSLog(@"error: got %@", [err localizedDescription]);
}];
[JSONCache sharedCache].expirationTimeInHours = kImmediatelyExpire;
[JSONCache sharedCache].expirationTimeInHoursWhenOffline = kNeverExpire;
[JSONCache sharedCache].revalidateCacheViaETagAfterTimeInHours = kAlwaysRevalidate;
[JSONCache sharedCache].revalidateCacheFromServerAfterTimeInHours = kAlwaysRevalidate;
[[JSONCache sharedCache] loadCacheFromDisc];
NSLog(@"cache: %@", [JSONCache sharedCache]);
[JSONHTTPClient setIsUsingJSONCache: YES];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(actionLoadCall:)];
*/
}

-(IBAction)actionLoadCall:(id)sender
Expand Down

0 comments on commit 90cb0ec

Please sign in to comment.