Issues on intial load
multinerd opened this issue · 1 comments
Maybe someone here can help me?
I am using magical MagicalRecord to save the results my barcode scanner app so that users can later review them (think scan history).
My issue is that i see (null)
(see image below) and the only way to get it loaded properly (discovered purely by dumb luck) is to swipe delete any single record.
This only happens when the app is launched and if i don't delete a record, it would remain null throughout the life of the app. Once i delete a record, it works fine for the life of the app.
My users shouldn't have to remove a record to have it loaded properly. What a i missing?
My setup is the following.
My model class
@interface BSCoreData : NSManagedObject
@property (nonatomic, strong) NSString *itemName, *itemUPC, *scanStore;
@property (nonatomic, strong) NSDate *scanTime;
@property (nonatomic, strong) NSData *itemImage;
@end
UITableViewController
- (void)viewDidLoad {
...
listOfScans = [BSCoreData MR_findAllSortedBy:@"scanTime" ascending:NO]; // listOfScans = NSArray
[self.tableView reloadData];
...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
BSCoreData *data = [listOfScans objectAtIndex:indexPath.row];
...
// This is how im deleting a record using `MGSwipeTableCell`
cell.rightButtons = @[[MGSwipeButton buttonWithTitle:@""
icon:[[UIImage imageNamed:@"UI-Delete"] rt_tintedImageWithColor:[UIColor appTint]]
backgroundColor:[UIColor deleteColor]
callback:^BOOL(MGSwipeTableCell *sender) {
[data MR_deleteEntity];
listOfScans = [BSCoreData MR_findAllSortedBy:@"scanTime" ascending:NO]; // listOfScans = NSArray
[weakself.tableView reloadData];
return YES;
}]];
...
}
This seems to have fixed itself after i added a new bool property to my model.