Skip to content

zhangxigithub/AutomaticCoder

Repository files navigation

Automatic Coder

Function 1: Transform json data into model file (perfect fitting MJExtension)

功能1:json数据转模型文件(完美适配MJExtension)

截图2

Function 2: Automatic create view code

功能2:自动生成控件代码

截图1

Overview

Automatic generate Objective-C code by JSON string.Support <NSCoding>.

Do you want other code?Tell me i'll add it.

System

Xcode 4.4 or later

Mac OS 10.7 or later

Feedback

http://zhangxi.me

zhangxi_1989@sina.com

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://zxapi.sinaapp.com"]];
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSDictionary *json = [data objectFromJSONData];
    
    //init object
    Person *person = [[Person alloc] initWithJson:json];
    NSLog(@"%@",person.name);                //http://zhangxi.me
    NSLog(@"%@",person.male?@"男":@"女");     //男
    NSLog(@"%ld",person.girlFriends.count);   //3
    
    
    //write to file
    BOOL result = [NSKeyedArchiver archiveRootObject:person toFile:@"./person.data"];
    NSLog(@"%@",result?@"success":@"failure");   //success

    
    //read from file
    Person *thePerson = [NSKeyedUnarchiver unarchiveObjectWithFile:@"./person.data"];
   
    NSLog(@"%@",thePerson.name);                //http://zhangxi.me
    NSLog(@"%@",thePerson.male?@"男":@"女");     //男
    NSLog(@"%ld",thePerson.girlFriends.count);   ///3

About

Automatic generate Objective-C code by JSON string.Support <NSCoding> .

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published