From 0abf0548259151a50ed6c4e484f5ccb15d8621f0 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 19 May 2017 11:20:47 -0400 Subject: [PATCH] null checks on _tableItems --- src/iOS.Extension/LoginListViewController.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/iOS.Extension/LoginListViewController.cs b/src/iOS.Extension/LoginListViewController.cs index 0cbf4db9f..1993bfb60 100644 --- a/src/iOS.Extension/LoginListViewController.cs +++ b/src/iOS.Extension/LoginListViewController.cs @@ -115,7 +115,7 @@ namespace Bit.iOS.Extension { var loginService = Resolver.Resolve(); var logins = await loginService.GetAllAsync(_context.UrlString); - _tableItems = logins?.Item1.Select(s => new LoginViewModel(s)) + _tableItems = logins?.Item1?.Select(s => new LoginViewModel(s)) .OrderBy(s => s.Name) .ThenBy(s => s.Username) .ToList() ?? new List(); @@ -125,12 +125,12 @@ namespace Bit.iOS.Extension public override nint RowsInSection(UITableView tableview, nint section) { - return _tableItems.Count() == 0 ? 1 : _tableItems.Count(); + return _tableItems == null || _tableItems.Count() == 0 ? 1 : _tableItems.Count(); } public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { - if(_tableItems.Count() == 0) + if(_tableItems == null || _tableItems.Count() == 0) { var noDataCell = new UITableViewCell(UITableViewCellStyle.Default, "NoDataCell"); noDataCell.TextLabel.Text = AppResources.NoLoginsTap; @@ -154,7 +154,7 @@ namespace Bit.iOS.Extension public override void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath) { - if(_tableItems.Count() == 0 || cell == null) + if(_tableItems == null || _tableItems.Count() == 0 || cell == null) { return; } @@ -169,7 +169,7 @@ namespace Bit.iOS.Extension tableView.DeselectRow(indexPath, true); tableView.EndEditing(true); - if(_tableItems.Count() == 0) + if(_tableItems == null || _tableItems.Count() == 0) { _controller.PerformSegue("loginAddSegue", this); return;