Persistence Layer Note DAO h interface Note DAO

  • Slides: 37
Download presentation

Persistence Layer(数据持久� )

Persistence Layer(数据持久� )

Note. DAO. h代� @interface Note. DAO : NSObject //保存数据列表 @property (nonatomic, strong) NSMutable. Array*

Note. DAO. h代� @interface Note. DAO : NSObject //保存数据列表 @property (nonatomic, strong) NSMutable. Array* list. Data; + (Note. DAO*)shared. Manager; //插入Note方法 -(int) create: (Note*)model; //� 除Note方法 -(int) remove: (Note*)model; //修改Note方法 -(int) modify: (Note*)model; //�� 所有数据方法 -(NSMutable. Array*) find. All; //按照主��� 数据方法 -(Note*) find. By. Id: (Note*)model; @end 16 智捷i. OS� 堂

� 例�� DAO static Note. DAO *shared. Manager = nil; + (Note. DAO*)shared. Manager

� 例�� DAO static Note. DAO *shared. Manager = nil; + (Note. DAO*)shared. Manager { static dispatch_once_t once; dispatch_once(&once, ^{ shared. Manager = [[self alloc] init]; . . . }); return shared. Manager; } 17 智捷i. OS� 堂

插入和� 除方法 //插入Note方法 -(int) create: (Note*)model { [self. list. Data add. Object: model]; return

插入和� 除方法 //插入Note方法 -(int) create: (Note*)model { [self. list. Data add. Object: model]; return 0; } //� 除Note方法 -(int) remove: (Note*)model { for (Note* note in self. list. Data) { //比� 日期主� 是否相等 if ([note. date is. Equal. To. Date: model. date]){ [self. list. Data remove. Object: note]; break; } } return 0; } 18 智捷i. OS� 堂

修改方法 //修改Note方法 -(int) modify: (Note*)model { for (Note* note in self. list. Data) {

修改方法 //修改Note方法 -(int) modify: (Note*)model { for (Note* note in self. list. Data) { //比� 日期主� 是否相等 if ([note. date is. Equal. To. Date: model. date]){ note. content = model. content; break; } } return 0; } 19 智捷i. OS� 堂

�� 方法 //�� 所有数据方法 -(NSMutable. Array*) find. All { return self. list. Data; }

�� 方法 //�� 所有数据方法 -(NSMutable. Array*) find. All { return self. list. Data; } //按照主��� 数据方法 -(Note*) find. By. Id: (Note*)model { for (Note* note in self. list. Data) { //比� 日期主� 是否相等 if ([note. date is. Equal. To. Date: model. date]){ return note; } } return nil; } 20 智捷i. OS� 堂

Domain中Note // // Note. h #import <Foundation/Foundation. h> @interface Note : NSObject @property(nonatomic, strong)

Domain中Note // // Note. h #import <Foundation/Foundation. h> @interface Note : NSObject @property(nonatomic, strong) NSDate* date; @property(nonatomic, strong) NSString* content; @end // // Note. m #import "Note. h" @implementation Note @end 21 智捷i. OS� 堂

Business. Logic Layer(����� )

Business. Logic Layer(����� )

Note. BL. m //插入Note方法 -(NSMutable. Array*) create. Note: (Note*)model { Note. DAO *dao =

Note. BL. m //插入Note方法 -(NSMutable. Array*) create. Note: (Note*)model { Note. DAO *dao = [Note. DAO shared. Manager]; [dao create: model]; return [dao find. All]; } //� 除Note方法 -(NSMutable. Array*) remove: (Note*)model { Note. DAO *dao = [Note. DAO shared. Manager]; [dao remove: model]; return [dao find. All]; } //�� 所有数据方法 -(NSMutable. Array*) find. All { Note. DAO *dao = [Note. DAO shared. Manager]; return [dao find. All]; } 24 智捷i. OS� 堂

Presentation Layer(表示� )

Presentation Layer(表示� )

App. Delegate. h和App. Delegate. m,� 用程序委托� 象; Master. View. Controller. h和Master. View. Controller. m,Master��

App. Delegate. h和App. Delegate. m,� 用程序委托� 象; Master. View. Controller. h和Master. View. Controller. m,Master�� 控制器; Detail. View. Controller. h和Detail. View. Controller. m,Detail�� 控制器; Add. View. Controller. h和Add. View. Controller. m,Add�� 控制器; Main. Storyboard_i. Phone. storyboard,i. Phone版的故事板文件; Main. Storyboard_i. Pad. storyboard,i. Pad版的故事板文件。 26 智捷i. OS� 堂

判断�� if ([[UIDevice current. Device] user. Interface. Idiom] == UIUser. Interface. Idiom. Phone) {

判断�� if ([[UIDevice current. Device] user. Interface. Idiom] == UIUser. Interface. Idiom. Phone) { CGSize screen. Size = [[UIScreen main. Screen] bounds]. size; // i. Phone�� if (screen. Size. height > 480. 0 f) { // i. Phone 5 �� } else { // i. Phone 5 之前�� } } else { // i. Pad �� } 27 智捷i. OS� 堂

�� Tel: 158 -0157 -7739 Mail: ios@51 work 6. com 新浪微博:@tony_关� 升 博客:CSDN:http: //blog.

�� Tel: 158 -0157 -7739 Mail: ios@51 work 6. com 新浪微博:@tony_关� 升 博客:CSDN:http: //blog. csdn. net/tonny_guan 51 CTO:http: //2009315319. blog. 51 cto. com/