Last active
March 22, 2020 08:21
Revisions
-
lukeredpath revised this gist
Aug 9, 2013 . 2 changed files with 69 additions and 74 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,31 +1,65 @@ // // FRSearchableIndexCollation.m // // // Copyright (c) 2010 Luke Redpath // Licensed under the MIT License // #import "LRIndexedCollationWithSearch.h" @implementation LRIndexedCollationWithSearch { UILocalizedIndexedCollation *_collation; } @dynamic sectionTitles; @dynamic sectionIndexTitles; + (id)currentCollation; { UILocalizedIndexedCollation *collation = [UILocalizedIndexedCollation currentCollation]; return [[self alloc] initWithCollation:collation]; } - (id)initWithCollation:(UILocalizedIndexedCollation *)collation; { if (self = [super init]) { _collation = collation; } return self; } #pragma mark - - (NSInteger)sectionForObject:(id)object collationStringSelector:(SEL)selector { return [_collation sectionForObject:object collationStringSelector:selector]; } - (NSInteger)sectionForSectionIndexTitleAtIndex:(NSInteger)indexTitleIndex { if(indexTitleIndex == 0) { return NSNotFound; } return [_collation sectionForSectionIndexTitleAtIndex:indexTitleIndex-1]; } - (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector { return [_collation sortedArrayFromArray:array collationStringSelector:selector]; } #pragma mark - #pragma mark Accessors - (NSArray *)sectionTitles; { return [_collation sectionTitles]; } - (NSArray *)sectionIndexTitles; { return [[NSArray arrayWithObject:UITableViewIndexSearch] arrayByAddingObjectsFromArray:[_collation sectionIndexTitles]]; } @end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,70 +1,31 @@ // // LRSearchableIndexCollation.m // // // Copyright (c) 2010 Luke Redpath // Licensed under the MIT License // #import <UIKit/UIKit.h> /* A simple decorator around UILocalizedIndexedCollation that inserts the {{search}} magnifying glass icon into the section index titles and adjusts the section index as necessary to account for the extra index item. Use as a direct replacement for UILocalizedIndexedCollation in indexed table views that have a search interface. */ @interface LRIndexedCollationWithSearch : NSObject @property(nonatomic, readonly) NSArray *sectionTitles; @property(nonatomic, readonly) NSArray *sectionIndexTitles; + (id)currentCollation; - (id)initWithCollation:(UILocalizedIndexedCollation *)collation; - (NSInteger)sectionForObject:(id)object collationStringSelector:(SEL)selector; - (NSInteger)sectionForSectionIndexTitleAtIndex:(NSInteger)indexTitleIndex; - (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector; @end -
lukeredpath revised this gist
Sep 2, 2010 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
lukeredpath revised this gist
Sep 2, 2010 . 3 changed files with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // // LRSearchableIndexCollation.m // // // Copyright (c) 2010 Luke Redpath @@ -16,7 +16,7 @@ Use as a direct replacement for UILocalizedIndexedCollation in indexed table views that have a search interface. */ @interface LRIndexedCollationWithSearch : NSObject { UILocalizedIndexedCollation *collation; } @property(nonatomic, readonly) NSArray *sectionTitles; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,10 @@ // Licensed under the MIT License // #import "LRIndexedCollationWithSearch" @implementation LRIndexedCollationWithSearch @dynamic sectionTitles; @dynamic sectionIndexTitles; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,20 @@ // example usage of LRIndexedCollationWithSearch within your UITableView delegate methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [[[LRIndexedCollationWithSearch currentCollation] sectionTitles] count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [[[LRIndexedCollationWithSearch currentCollation] sectionTitles] objectAtIndex:section]; } - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { return [[LRIndexedCollationWithSearch currentCollation] sectionIndexTitles]; } - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { return [[LRIndexedCollationWithSearch currentCollation] sectionForSectionIndexTitleAtIndex:index]; } -
lukeredpath revised this gist
Feb 19, 2010 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ // example usage of FRIndexedCollationWithSearch within your UITableView delegate methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return [[[FRIndexedCollationWithSearch currentCollation] sectionTitles] count]; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return [[[FRIndexedCollationWithSearch currentCollation] sectionTitles] objectAtIndex:section]; } - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { return [[FRIndexedCollationWithSearch currentCollation] sectionIndexTitles]; } - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { return [[FRIndexedCollationWithSearch currentCollation] sectionForSectionIndexTitleAtIndex:index]; } -
lukeredpath revised this gist
Feb 16, 2010 . 3 changed files with 25 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ // // FRSearchableIndexCollation.m // // // Copyright (c) 2010 Luke Redpath // Licensed under the MIT License // #import <UIKit/UIKit.h> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ // // FRSearchableIndexCollation.m // // // Copyright (c) 2010 Luke Redpath // Licensed under the MIT License // #import "FRIndexedCollationWithSearch.h" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ Copyright (c) 2010 Luke Redpath Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -
lukeredpath revised this gist
Feb 16, 2010 . 2 changed files with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // // LJSearchableIndexCollation.h // // // Created by Luke Redpath on 16/02/2010. @@ -25,7 +25,7 @@ + (id)currentCollation; - (id)initWithCollation:(UILocalizedIndexedCollation *)_collation; - (NSInteger)sectionForObject:(id)object collationStringSelector:(SEL)selector; - (NSInteger)sectionForSectionIndexTitleAtIndex:(NSInteger)indexTitleIndex; - (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector; @end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // // LJSearchableIndexCollation.m // // // Created by Luke Redpath on 16/02/2010. @@ -51,7 +51,7 @@ - (NSInteger)sectionForSectionIndexTitleAtIndex:(NSInteger)indexTitleIndex - (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector { return [collation sortedArrayFromArray:array collationStringSelector:selector]; } #pragma mark - -
lukeredpath revised this gist
Feb 16, 2010 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // // FRSearchableIndexCollation.h // // // Created by Luke Redpath on 16/02/2010. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ // // FRSearchableIndexCollation.m // // // Created by Luke Redpath on 16/02/2010. -
lukeredpath revised this gist
Feb 16, 2010 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ // Copyright 2010 LJR Software Limited. All rights reserved. // #import <UIKit/UIKit.h> /* A simple decorator around UILocalizedIndexedCollation that inserts the @@ -16,7 +16,7 @@ Use as a direct replacement for UILocalizedIndexedCollation in indexed table views that have a search interface. */ @interface FRIndexedCollationWithSearch : NSObject { UILocalizedIndexedCollation *collation; } @property(nonatomic, readonly) NSArray *sectionTitles; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,10 @@ // Copyright 2010 LJR Software Limited. All rights reserved. // #import "FRIndexedCollationWithSearch.h" @implementation FRIndexedCollationWithSearch @dynamic sectionTitles; @dynamic sectionIndexTitles; -
lukeredpath created this gist
Feb 16, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ // // LJSearchableIndexCollation.h // // // Created by Luke Redpath on 16/02/2010. // Copyright 2010 LJR Software Limited. All rights reserved. // #import <Foundation/Foundation.h> /* A simple decorator around UILocalizedIndexedCollation that inserts the {{search}} magnifying glass icon into the section index titles and adjusts the section index as necessary to account for the extra index item. Use as a direct replacement for UILocalizedIndexedCollation in indexed table views that have a search interface. */ @interface FRSearchableIndexCollation : NSObject { UILocalizedIndexedCollation *collation; } @property(nonatomic, readonly) NSArray *sectionTitles; @property(nonatomic, readonly) NSArray *sectionIndexTitles; + (id)currentCollation; - (id)initWithCollation:(UILocalizedIndexedCollation *)_collation; - (NSInteger)sectionForObject:(id)object collationStringSelector:(SEL)selector - (NSInteger)sectionForSectionIndexTitleAtIndex:(NSInteger)indexTitleIndex - (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector @end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ // // LJSearchableIndexCollation.m // // // Created by Luke Redpath on 16/02/2010. // Copyright 2010 LJR Software Limited. All rights reserved. // #import "FRSearchableIndexCollation.h" @implementation FRSearchableIndexCollation @dynamic sectionTitles; @dynamic sectionIndexTitles; + (id)currentCollation; { UILocalizedIndexedCollation *collation = [UILocalizedIndexedCollation currentCollation]; return [[[self alloc] initWithCollation:collation] autorelease]; } - (id)initWithCollation:(UILocalizedIndexedCollation *)_collation; { if (self = [super init]) { collation = [_collation retain]; } return self; } - (void)dealloc; { [collation release]; [super dealloc]; } #pragma mark - - (NSInteger)sectionForObject:(id)object collationStringSelector:(SEL)selector { return [collation sectionForObject:object collationStringSelector:selector]; } - (NSInteger)sectionForSectionIndexTitleAtIndex:(NSInteger)indexTitleIndex { if(indexTitleIndex == 0) { return NSNotFound; } return [collation sectionForSectionIndexTitleAtIndex:indexTitleIndex-1]; } - (NSArray *)sortedArrayFromArray:(NSArray *)array collationStringSelector:(SEL)selector { [collation sortedArrayFromArray:array collationStringSelector:selector]; } #pragma mark - #pragma mark Accessors - (NSArray *)sectionTitles; { return [collation sectionTitles]; } - (NSArray *)sectionIndexTitles; { return [[NSArray arrayWithObject:UITableViewIndexSearch] arrayByAddingObjectsFromArray:[collation sectionIndexTitles]]; } @end