forked from organicmaps/organicmaps
[ios] Fixed crash with highlighted range.
This commit is contained in:
parent
be1e163758
commit
c15e6392e7
1 changed files with 16 additions and 3 deletions
|
@ -1,8 +1,11 @@
|
|||
#import "MWMSearchCell.h"
|
||||
#import "Statistics.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
@interface MWMSearchCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
|
||||
|
@ -45,9 +48,19 @@
|
|||
size_t const rangesCount = result.GetHighlightRangesCount();
|
||||
for (size_t i = 0; i < rangesCount; ++i)
|
||||
{
|
||||
pair<uint16_t, uint16_t> const range = result.GetHighlightRange(i);
|
||||
[attributedTitle addAttributes:selectedTitleAttributes
|
||||
range:NSMakeRange(range.first, range.second)];
|
||||
pair<uint16_t, uint16_t> const & range = result.GetHighlightRange(i);
|
||||
|
||||
if (range.first + range.second <= title.length)
|
||||
{
|
||||
[attributedTitle addAttributes:selectedTitleAttributes range:NSMakeRange(range.first, range.second)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[Statistics logEvent:@"Incorrect_highlight_range" withParametrs:@{@"range.first" : @(range.first),
|
||||
@"range.second" : @(range.second),
|
||||
@"string" : title}];
|
||||
LOG(LERROR, ("Incorrect range: ", range, " for string: ", result.GetString()));
|
||||
}
|
||||
}
|
||||
self.titleLabel.attributedText = attributedTitle;
|
||||
[self.titleLabel sizeToFit];
|
||||
|
|
Loading…
Add table
Reference in a new issue