I am having following error while using native iOS phones (but it is not happening on iPhone Simulator)
-[TKDataSource itemAtIndex:forSection:]NSRangeException: *** -[__NSArrayM objectAtIndexedSubscript:]: index 12 beyond bounds [0 .. 0]
Below is the XAML I am using:
<telerikDataControls:RadListView Grid.Row="2" VerticalOptions="StartAndExpand" LoadOnDemandMode="Manual" ItemsSource="{Binding Records}" SelectedItem="{Binding SelectedRecord}" IsLoadOnDemandEnabled="true" IsPullToRefreshEnabled="false"> <telerikDataControls:RadListView.ItemTemplate> <DataTemplate> <telerikListView:ListViewTemplateCell> <telerikListView:ListViewTemplateCell.View> <Grid> <StackLayout Spacing="2" Margin="20,5,5,5"> <Label Text="{Binding Title}" FontSize="16" LineBreakMode="TailTruncation" FontAttributes="Bold" /> <Label Text="{Binding Subtitle}" LineBreakMode="TailTruncation" FontSize="14" TextColor="Gray" /> </StackLayout> </Grid> </telerikListView:ListViewTemplateCell.View> </telerikListView:ListViewTemplateCell> </DataTemplate> </telerikDataControls:RadListView.ItemTemplate> <telerikDataControls:RadListView.LayoutDefinition> <telerikListView:ListViewLinearLayout ItemLength="50" /> </telerikDataControls:RadListView.LayoutDefinition> </telerikDataControls:RadListView>
Below is the ViewModel.cs which sets Records:
private ObservableCollection<ViewRecordItem> _records=new ObservableCollection<ViewRecordItem>();public ObservableCollection<ViewRecordItem> Records { get => _records; set { _records = value; OnPropertyChanged(); } }private async Task Search(bool isNew = true) { try { IsBusy = true; CanRefresh = true; if (isNew) _page = 1; else _page++; ViewRecordItem[] recs = await svc.GetViewRecordItems(MyViewItem, page: _page, filter: GetFilters()); if (isNew) Records.Clear(); if (recs.Length == 0) { throw new Exception("Search could find any record."); } foreach (var rec in recs) { Records.Add(rec); } } catch (Exception ex) { AlertService.Instance.ShowMsg(ex.Message); CanRefresh = false; } IsBusy = false; }
Below is the crash report from Mobile Center
CoreFoundation __exceptionPreprocesslibobjc.A.dylib objc_exception_throwCoreFoundation _CFThrowFormattedExceptionCoreFoundation -[__NSArrayM objectAtIndexedSubscript:]ExelareMobile.iOS -[TKDataSource itemAtIndex:forSection:]ExelareMobile.iOS -[TKDataSource listView:cellForItemAtIndexPath:]ExelareMobile.iOS -[TKListView collectionView:cellForItemAtIndexPath:]UIKit-[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:]UIKit-[UICollectionView _updateVisibleCellsNow:]UIKit-[UICollectionView layoutSubviews]UIKit-[UIView(CALayerDelegate) layoutSublayersOfLayer:]