Skip to content

Instantly share code, notes, and snippets.

@DLSteve
Created March 26, 2016 19:13
Show Gist options
  • Save DLSteve/812ebb274b99f1ada471 to your computer and use it in GitHub Desktop.
Save DLSteve/812ebb274b99f1ada471 to your computer and use it in GitHub Desktop.
Realm Seed
- (IBAction)didClickAddButton:(UIBarButtonItem *)sender {
NSArray *time = @[@"10:00", @"11:00", @"12:00", @"1:00", @"2:00", @"3:00", @"4:00", @"5:00", @"6:00", @"7:00", @"8:00"];
NSArray *zoneName = @[@"Vestibule / Front End Area",@"Sales Floor",@"Receiving Area",@"Building Specific",];
NSArray *checkItems = @[
@[@"Trash, spills & trip hazards",@"Electrical hazards",@"Emergency exits",@"Optical",@"Entrance / Exit"],
@[@"Trash, spills & trip hazards",@"Electrical hazards",@"Emergency exits",@"Merchandise issues",@"Road shows",@"Unattended pallet jacks",@"Walk-in coolers",@"Demo areas",@"Display safety",@"Jewelry / Alarmed displays"],
@[@"Trash, spills & trip hazards",@"Electrical hazards",@"Emergency exits",@"Safe stacks / storage",@"Roof hatch",@"Overhead heaters",@"Compactors",@"Re-wrap machine",@"RTV",@"Receiving doors",@"Eye wash station"],
@[]
];
for (int i = 0; i < time.count; i++) {
FloorWalk *walk = [FloorWalk floorWalkWithTimePeriod:time[i]];
for (int i = 0; i < zoneName.count; i++) {
NSNumber *zoneNumber = [NSNumber numberWithInt:i + 1];
NSArray *checkDesc = [NSArray arrayWithArray:checkItems[i]];
for (int j = 0; j < checkDesc.count; j++) {
Check *check = [Check checkWithZoneDescription:zoneName[i] zoneNumber:zoneNumber checkDescription:checkDesc[j]];
[walk.checks addObject:check];
}
}
[[RLMRealm defaultRealm] beginWriteTransaction];
[[RLMRealm defaultRealm] addObjectWithNotification:walk];
[[RLMRealm defaultRealm] commitWriteTransaction];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment