Skip to content

Commit 3b0d8a4

Browse files
jquick-axwaysgtcoolguy
authored andcommittedOct 21, 2020
fix(ios): tableview "sectionCount" property crash
Fixes TIMOB-13903
1 parent b8d2cd1 commit 3b0d8a4

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed
 

‎iphone/Classes/TiUITableView.m

+5-4
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ - (void)replaceData:(NSMutableArray *)data animation:(UITableViewRowAnimation)an
555555
//won't have any problems in the case that it is actually nil.
556556
TiUITableViewProxy *ourProxy = (TiUITableViewProxy *)[self proxy];
557557

558-
NSUInteger oldCount = [ourProxy sectionCount];
558+
NSUInteger oldCount = ourProxy.sectionCount.unsignedIntegerValue;;
559559

560560
for (TiUITableViewSectionProxy *section in [(TiUITableViewProxy *)[self proxy] internalSections]) {
561561
if ([section parent] == ourProxy) {
@@ -1313,7 +1313,8 @@ - (void)updateSearchResultIndexes
13131313
}
13141314
NSEnumerator *searchResultIndexEnumerator;
13151315
if (searchResultIndexes == nil) {
1316-
searchResultIndexes = [[NSMutableArray alloc] initWithCapacity:[(TiUITableViewProxy *)[self proxy] sectionCount]];
1316+
NSUInteger sectionCount = [(TiUITableViewProxy *)[self proxy] sectionCount].unsignedIntegerValue;
1317+
searchResultIndexes = [[NSMutableArray alloc] initWithCapacity:sectionCount];
13171318
searchResultIndexEnumerator = nil;
13181319
} else {
13191320
searchResultIndexEnumerator = [searchResultIndexes objectEnumerator];
@@ -2124,7 +2125,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)ourTableView
21242125
return 1;
21252126
}
21262127
// One quirk of UITableView is that it really hates having 0 sections. Instead, supply 1 section, no rows.
2127-
NSUInteger result = [(TiUITableViewProxy *)[self proxy] sectionCount];
2128+
NSUInteger result = [(TiUITableViewProxy *)[self proxy] sectionCount].unsignedIntegerValue;
21282129
return MAX(1, result);
21292130
}
21302131

@@ -2166,7 +2167,7 @@ - (void)tableView:(UITableView *)ourTableView commitEditingStyle:(UITableViewCel
21662167
[table beginUpdates];
21672168
if (emptySection) {
21682169
NSIndexSet *thisSectionSet = [NSIndexSet indexSetWithIndex:[indexPath section]];
2169-
if ([(TiUITableViewProxy *)[self proxy] sectionCount] > 0) {
2170+
if ([(TiUITableViewProxy *)[self proxy] sectionCount].unsignedIntegerValue > 0) {
21702171
[table deleteSections:thisSectionSet withRowAnimation:UITableViewRowAnimationFade];
21712172
} else //There always must be at least one section. So instead, we have it reload to clear out the header and footer, etc.
21722173
{

‎iphone/Classes/TiUITableViewProxy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
- (NSArray *)data;
2222
//Sections and Data are the sanitized version.
2323
@property (nonatomic, readwrite, copy) NSArray *sections;
24-
- (NSUInteger)sectionCount;
24+
- (NSNumber *)sectionCount;
2525

2626
#pragma mark NON-JS functionality
2727
//internalSections is until TODO: Stop JS from using ValueForKey

‎iphone/Classes/TiUITableViewProxy.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -882,9 +882,9 @@ - (void)willShow
882882
[(TiUITableView *)[self view] refreshSearchControllerUsingReload:YES];
883883
}
884884

885-
- (NSUInteger)sectionCount
885+
- (NSNumber *)sectionCount
886886
{ //TODO: Shouldn't this be in the main thread, too?
887-
return [sections count];
887+
return NUMUINTEGER((sections != nil) ? sections.count : 0);
888888
}
889889

890890
- (TiUITableViewSectionProxy *)tableSectionFromArg:(id)arg

0 commit comments

Comments
 (0)
Please sign in to comment.