Repository navigation
Expand file tree
/
Copy pathCUSModelFactory.m
More file actions
76 lines (66 loc) · 2.37 KB
/
Copy pathCUSModelFactory.m
File metadata and controls
76 lines (66 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// CUSModelFactory.m
// CUSFileStorageExample
//
// Created by zhangyu on 14-5-17.
// Copyright (c) 2014年 zhangyu. All rights reserved.
//
#import "CUSModelFactory.h"
#import <mach/mach_time.h>
CGFloat BNRTimeBlock (void (^block)(void)) {
mach_timebase_info_data_t info;
if (mach_timebase_info(&info) != KERN_SUCCESS) return -1.0;
uint64_t start = mach_absolute_time ();
block ();
uint64_t end = mach_absolute_time ();
uint64_t elapsed = end - start;
uint64_t nanos = elapsed * info.numer / info.denom;
return (CGFloat)nanos / NSEC_PER_SEC;
}
@implementation CUSModelFactory
+(CUSSchool *)createSchool{
CUSSchool *school = [[CUSSchool alloc]init];
school.schoolId = @"id0123456";
school.schoolName = @"qinghuadaxue";
school.schoolAddress = nil;
school.schoolPost = 123;
school.schoolFloat = 1234.5678;
school.boolValue = YES;
school.ch = 's';
school.schoolNumber = [NSNumber numberWithInt:6];
school.schoolDate = [NSDate date];
school.headmaster = [self createTeacher:99];
NSMutableArray *teacherArray = [NSMutableArray array];
for (int i = 0; i < 3; i++) {
[teacherArray addObject:[self createTeacher:i]];
}
school.teacherArray = teacherArray;
NSMutableDictionary *teacherDictionary = [NSMutableDictionary dictionary];
for (int i = 0; i < 5; i++) {
NSString *key = [NSString stringWithFormat:@"key%i",i];
[teacherDictionary setObject:[self createTeacher:i] forKey:key];
}
school.teacherDictionary = teacherDictionary;
return school;
}
+(CUSTeacher *)createTeacher:(NSInteger)index{
CUSTeacher *model = [[CUSTeacher alloc]init];
model.iden = [NSString stringWithFormat:@"teacherId%i",index];
model.name = [NSString stringWithFormat:@"teacherName%i",index];
model.age = 30 +index;
model.courseName = [NSString stringWithFormat:@"courseName%i",index];
NSMutableArray *array = [NSMutableArray array];
for (int i = 0; i < 2; i++) {
[array addObject:[self createStudent:i]];
}
model.studentArray = array;
return model;
}
+(CUSStudent *)createStudent:(NSInteger)index{
CUSStudent *model = [[CUSStudent alloc]init];
model.iden = [NSString stringWithFormat:@"studentId%i",index];
model.name = [NSString stringWithFormat:@"studentName%i",index];
model.age = 15 +index;
return model;
}
@end