This is a scaffold library and the aid of the project is providing all foundation functions for IOS
developer to build app easier.
When an object inherited 'A_DataModel', then it able to save the instance to plist file or sqlite database directly.
// ModelTest.h file
#import <A_IOSHelper/A_IOSHelper.h>
@interface TestDataModel : A_DataModel
@property (retain, nonatomic) NSString* Name;
@property (retain, nonatomic) NSDate* CreateDate;
@property (nonatomic) NSInteger Index;
@property (retain, nonatomic) NSNumber* ID;
@end
TestDataModel* _model1 = [[TestDataModel alloc] init];
[_model1 setName:@"Object_1"];
[_model1 setCreateDate: [NSDate date]];
[_model1 setID:@0];
[_model1 A_SaveToPlist];
NSArray* models = [TestDataModel A_GetFromPliste];
TestDataModel* _model = [[TestDataModel alloc] init];
[_model setIndex:1];
[_model setName:@"Object_1"];
[_model setCreateDate: [NSDate date]];
[_model setID:@1];
[_model A_SaveToPlist]; // The model has been saved.
[_model A_DeleteInPlist];
This function only clear same type of models.
For example, using [TestDataModel A_ClearFromPlist];
will clear only TestDataModels.
[TestDataModel A_ClearFromPlist];
This function will automatically generate Table if the table isn't exist in Sqlite.
TestDataModel* _model = [[TestDataModel alloc] init];
[_model setIndex:0];
[_model setName:@"Object_1"];
[_model setCreateDate: [NSDate date]];
[_model setID:@0];
[_model A_SaveToSqlite];
Searching certain type of models in Sqlite
NSArray* _ models = [TestDataModel A_SearchSqlite:@"`name` like '%object%'"];
OR
[TestDataModel A_SearchSqlite:@"" withBlock:^(id obj, NSArray *result) {
// TODO: Other operations with data result
//obj is self.view
} andArg:self.view];
Searching certain type of models with demo model.
TestDataModel* _model = [[TestDataModel alloc] init];
[_model setIndex:0];
// Searching models with index == 0
NSArray* _models =[_model A_SearchSimilarModelsInSqlite];
// OR
[_model1 A_SearchSimilarModelsInSqliteWithBlock:^(id obj, NSArray *result) {
XCTAssertTrue(result.count >= 1);
} andArg:nil];