Skip to content

Commit 92d948d

Browse files
author
zhuchao
committed
23
1 parent c66f80d commit 92d948d

6 files changed

Lines changed: 45 additions & 21 deletions

File tree

File renamed without changes.
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#import <Foundation/Foundation.h>
1010
#import "JSONKit.h"
11+
#import <stdio.h>
1112
typedef enum
1213
{
1314
kString = 0,
@@ -21,6 +22,7 @@ typedef enum
2122
@property(nonatomic,retain) NSString *path;
2223
@property(nonatomic,retain) NSMutableString *templateH;
2324
@property(nonatomic,retain) NSMutableString *templateM;
25+
-(void)startWithArgv:(NSArray *)arguments;
2426
-(NSMutableArray *)checkProperty:(NSString *)json fileName:(NSString *)fileName;
2527
-(NSString*)getJSONWithURL:(NSString *)strUrl;
2628
-(void)generateClass:(NSString *)jsonString fileName:(NSString *)name;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,29 @@
55
// Created by 朱潮 on 14-8-14.
66
// Copyright (c) 2014年 zhuchao. All rights reserved.
77
//
8+
89
#import "MakeFile.h"
910
#define templateHUrl @"https://raw.githubusercontent.com/zhuchaowe/mojo-database/master/h.strings"
1011
#define templateMUrl @"https://raw.githubusercontent.com/zhuchaowe/mojo-database/master/m.strings"
1112
@implementation MakeFile
1213

14+
-(void)startWithArgv:(NSArray *)arguments{
15+
if(arguments.count < 4){
16+
NSLog(@" fileName location jsonUrl is needed");
17+
return;
18+
}
19+
NSString *fileName = [arguments objectAtIndex:1];
20+
NSString *location = [arguments objectAtIndex:2];
21+
NSString *jsonUrl = [arguments objectAtIndex:3];
22+
23+
NSLog(@"%@ %@ %@",fileName,location,jsonUrl);
24+
self.path = location;
25+
NSString *json = [self getJSONWithURL:jsonUrl];
26+
NSMutableArray *array = [self checkProperty:json fileName:fileName];
27+
NSLog(@"%@",array);
28+
[self generateClass:json fileName:fileName];
29+
}
30+
1331
-(NSMutableArray *)checkProperty:(NSString *)json fileName:(NSString *)fileName {
1432
NSDictionary *dict = [json objectFromJSONString];
1533
if(dict == nil)

ModelCoder.podspec

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Pod::Spec.new do |s|
2+
s.name = "ModelCoder"
3+
s.version = "1.0"
4+
s.summary = "ModelCoder can Automatic generate Objective-C code by JSON string"
5+
s.homepage = "https://github.com/zhuchaowe/ModelCoder"
6+
s.social_media_url = "https://swift.08dream.com"
7+
s.platform = :osx,'10.7'
8+
s.license = { :type => "MIT", :file => "LICENSE" }
9+
s.author = { "zhuchao" => "[email protected]" }
10+
s.source = { :git => "https://github.com/zhuchaowe/ModelCoder.git",:tag=>"1.0"}
11+
s.requires_arc = true
12+
s.subspec 'JSONKit' do |sp|
13+
sp.source_files = 'Base/JSONKit/*.{h,m}'
14+
sp.requires_arc = false
15+
sp.prefix_header_contents = '#import "JSONKit.h"'
16+
end
17+
s.subspec 'MakeFile' do |sp|
18+
sp.source_files = 'Base/MakeFile/*.{h,m}'
19+
sp.requires_arc = true
20+
sp.prefix_header_contents = '#import "MakeFile.h"'
21+
end
22+
end

main.m

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,14 @@
44
//
55
// Created by 朱潮 on 14-8-14.
66
// Copyright (c) 2014年 zhuchao. All rights reserved.
7-
//
7+
// NSArray *arguments = @[@"123",@"Test",@"/Users/huwei/Desktop/objc",@"http://test-leway.zjseek.com.cn:8000/api/goods/listCategories"];
88

9-
#import <Foundation/Foundation.h>
10-
#import <stdio.h>
119
#import "MakeFile.h"
1210

1311
int main(int argc, const char * argv[]) {
1412
@autoreleasepool {
15-
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
16-
if(arguments.count < 4){
17-
NSLog(@" fileName location jsonUrl is needed");
18-
return 0;
19-
}
20-
// NSArray *arguments = @[@"123",@"Test",@"/Users/huwei/Desktop/objc",@"http://test-leway.zjseek.com.cn:8000/api/goods/listCategories"];
21-
NSString *fileName = [arguments objectAtIndex:1];
22-
NSString *location = [arguments objectAtIndex:2];
23-
NSString *jsonUrl = [arguments objectAtIndex:3];
24-
25-
NSLog(@"%@ %@ %@",fileName,location,jsonUrl);
2613
MakeFile *make = [[MakeFile alloc] init];
27-
make.path = location;
28-
NSString *json = [make getJSONWithURL:jsonUrl];
29-
NSMutableArray *array = [make checkProperty:json fileName:fileName];
30-
NSLog(@"%@",array);
31-
32-
[make generateClass:json fileName:fileName];
14+
[make startWithArgv:[[NSProcessInfo processInfo] arguments]];
3315
}
3416
return 0;
35-
}
17+
}

0 commit comments

Comments
 (0)