Skip to content

Commit

Permalink
Search IPAs by name
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced committed Jan 9, 2012
1 parent c81cc31 commit cec8d75
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 33 deletions.
43 changes: 31 additions & 12 deletions Classes/IPAViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "AppDelegate.h"
#import "ArtworkViewController.h"
#import "IPAArchive.h"
#import "NSString+IPAArchive.h"

@implementation IPAViewController

Expand All @@ -19,7 +20,10 @@ @implementation IPAViewController
- (void) reloadRowsAtIndexPaths:(NSArray *)indexPaths
{
if ([NSThread isMainThread])
{
[self.tableView reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationFade];
[self.searchDisplayController.searchResultsTableView reloadData];
}
else
[self performSelectorOnMainThread:_cmd withObject:indexPaths waitUntilDone:NO];
}
Expand Down Expand Up @@ -55,16 +59,9 @@ - (void) loadArchives
[archivePool drain];
}

[self performSelectorOnMainThread:@selector(archivesDidLoad) withObject:nil waitUntilDone:NO];

[pool drain];
}

- (void) archivesDidLoad
{
[self.tableView reloadData];
}

- (void) viewDidLoad
{
self.title = self.tabBarItem.title;
Expand All @@ -80,9 +77,22 @@ - (void) viewDidUnload

// MARK: - UITableView data source

- (NSMutableArray *) archivesForTableView:(UITableView *)tableView
{
NSMutableArray *archives = self.archives;
if (tableView == self.searchDisplayController.searchResultsTableView)
{
NSString *searchText = [NSString stringWithFormat:@"*%@*", self.searchDisplayController.searchBar.text];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"appName LIKE[c] %@", searchText];
archives = [NSMutableArray arrayWithArray:[archives filteredArrayUsingPredicate:predicate]];
}

return archives;
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.archives count];
return [[self archivesForTableView:tableView] count];
}

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Expand All @@ -98,25 +108,34 @@ - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
IPAArchive *archive = [self.archives objectAtIndex:indexPath.row];
IPAArchive *archive = [[self archivesForTableView:tableView] objectAtIndex:indexPath.row];
NSString *path = [archive isKindOfClass:[IPAArchive class]] ? archive.path : (NSString *)archive;
UIImage *icon = [archive isKindOfClass:[IPAArchive class]] ? archive.appIcon : [UIImage imageNamed:@"Unknown.png"];

cell.textLabel.text = [[path lastPathComponent] stringByDeletingPathExtension];
cell.textLabel.text = [path appName];
cell.imageView.image = icon;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
IPAArchive *archive = [self.archives objectAtIndex:indexPath.row];
NSMutableArray *archives = [self archivesForTableView:tableView];
IPAArchive *archive = [archives objectAtIndex:indexPath.row];
if (![archive isKindOfClass:[IPAArchive class]])
{
NSString *path = (NSString *)archive;
archive = [[[IPAArchive alloc] initWithPath:path] autorelease];
[self.archives replaceObjectAtIndex:indexPath.row withObject:archive];
[archives replaceObjectAtIndex:indexPath.row withObject:archive];
}
ArtworkViewController *artworkViewController = [[[ArtworkViewController alloc] initWithArchive:archive] autorelease];
[self.navigationController pushViewController:artworkViewController animated:YES];
}

// MARK: - Search Display Delegate

- (void) searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView
{
tableView.backgroundColor = self.tableView.backgroundColor;
tableView.rowHeight = self.tableView.rowHeight;
}

@end
15 changes: 15 additions & 0 deletions Classes/NSString+IPAArchive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSString+IPAArchive.h
// UIKit Artwork Extractor
//
// Created by Cédric Luthi on 09.01.12.
// Copyright (c) 2012 Cédric Luthi. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (IPAArchive)

- (NSString *) appName;

@end
18 changes: 18 additions & 0 deletions Classes/NSString+IPAArchive.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// NSString+IPAArchive.m
// UIKit Artwork Extractor
//
// Created by Cédric Luthi on 09.01.12.
// Copyright (c) 2012 Cédric Luthi. All rights reserved.
//

#import "NSString+IPAArchive.h"

@implementation NSString (IPAArchive)

- (NSString *) appName
{
return [[self lastPathComponent] stringByDeletingPathExtension];
}

@end
115 changes: 94 additions & 21 deletions IPAViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
<string key="NS.object.0">933</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
<string>IBUISearchDisplayController</string>
<string>IBUITableView</string>
<string>IBUISearchBar</string>
<string>IBProxyObject</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Expand All @@ -33,9 +35,24 @@
<object class="IBUITableView" id="687842835">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<array class="NSMutableArray" key="NSSubviews">
<object class="IBUISearchBar" id="465005046">
<reference key="NSNextResponder" ref="687842835"/>
<int key="NSvFlags">290</int>
<string key="NSFrameSize">{320, 44}</string>
<reference key="NSSuperview" ref="687842835"/>
<reference key="NSWindow"/>
<int key="IBUIContentMode">3</int>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="IBUITextInputTraits" key="IBTextInputTraits">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
</array>
<string key="NSFrameSize">{320, 460}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC43NQA</bytes>
Expand All @@ -52,6 +69,10 @@
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">22</float>
<float key="IBUISectionFooterHeight">22</float>
<reference key="IBUITableHeaderView" ref="465005046"/>
</object>
<object class="IBUISearchDisplayController" id="1054454063">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
Expand All @@ -64,6 +85,62 @@
</object>
<int key="connectionID">4</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">searchDisplayController</string>
<reference key="source" ref="841351856"/>
<reference key="destination" ref="1054454063"/>
</object>
<int key="connectionID">15</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="465005046"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">20</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">searchContentsController</string>
<reference key="source" ref="1054454063"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">16</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">searchResultsDataSource</string>
<reference key="source" ref="1054454063"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">17</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">searchResultsDelegate</string>
<reference key="source" ref="1054454063"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">18</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1054454063"/>
<reference key="destination" ref="841351856"/>
</object>
<int key="connectionID">19</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">searchBar</string>
<reference key="source" ref="1054454063"/>
<reference key="destination" ref="465005046"/>
</object>
<int key="connectionID">14</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
Expand All @@ -87,47 +164,43 @@
<object class="IBObjectRecord">
<int key="objectID">2</int>
<reference key="object" ref="687842835"/>
<array class="NSMutableArray" key="children">
<reference ref="465005046"/>
</array>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="1054454063"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">12</int>
<reference key="object" ref="465005046"/>
<reference key="parent" ref="687842835"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.CustomClassName">IPAViewController</string>
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="12.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="13.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">11</int>
<int key="maxID">20</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">IPAViewController</string>
<string key="superclassName">UITableViewController</string>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="appNameLabel">UILabel</string>
<string key="archiveLoadingView">UIView</string>
<string key="progressView">UIProgressView</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="appNameLabel">
<string key="name">appNameLabel</string>
<string key="candidateClassName">UILabel</string>
</object>
<object class="IBToOneOutletInfo" key="archiveLoadingView">
<string key="name">archiveLoadingView</string>
<string key="candidateClassName">UIView</string>
</object>
<object class="IBToOneOutletInfo" key="progressView">
<string key="name">progressView</string>
<string key="candidateClassName">UIProgressView</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/IPAViewController.h</string>
Expand Down
6 changes: 6 additions & 0 deletions UIKit Artwork Extractor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
DAB5337B14B3C65500EDDE37 /* IPA@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB5337914B3C65500EDDE37 /* IPA@2x.png */; };
DAB5337D14B3C67500EDDE37 /* IPAViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DAB5337C14B3C67500EDDE37 /* IPAViewController.xib */; };
DAC796A011FD71E100A33F28 /* ArtworkDetailViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DAC7969F11FD71E100A33F28 /* ArtworkDetailViewController.xib */; };
DAD7253F14BB9A80001ED756 /* NSString+IPAArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD7253E14BB9A7F001ED756 /* NSString+IPAArchive.m */; };
DAF387911211AF30003DF2B8 /* UITintedGlassButtonHighlight@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAF3878D1211AF30003DF2B8 /* UITintedGlassButtonHighlight@2x.png */; };
DAF387921211AF30003DF2B8 /* UITintedGlassButtonMask@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAF3878E1211AF30003DF2B8 /* UITintedGlassButtonMask@2x.png */; };
DAF387931211AF30003DF2B8 /* UITintedGlassButtonShadow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DAF3878F1211AF30003DF2B8 /* UITintedGlassButtonShadow@2x.png */; };
Expand Down Expand Up @@ -134,6 +135,8 @@
DAB5337914B3C65500EDDE37 /* IPA@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "IPA@2x.png"; path = "Resources/IPA@2x.png"; sourceTree = "<group>"; };
DAB5337C14B3C67500EDDE37 /* IPAViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IPAViewController.xib; sourceTree = SOURCE_ROOT; };
DAC7969F11FD71E100A33F28 /* ArtworkDetailViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ArtworkDetailViewController.xib; path = ../ArtworkDetailViewController.xib; sourceTree = "<group>"; };
DAD7253D14BB9A7F001ED756 /* NSString+IPAArchive.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+IPAArchive.h"; sourceTree = "<group>"; };
DAD7253E14BB9A7F001ED756 /* NSString+IPAArchive.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+IPAArchive.m"; sourceTree = "<group>"; };
DAF3878D1211AF30003DF2B8 /* UITintedGlassButtonHighlight@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "UITintedGlassButtonHighlight@2x.png"; sourceTree = "<group>"; };
DAF3878E1211AF30003DF2B8 /* UITintedGlassButtonMask@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "UITintedGlassButtonMask@2x.png"; sourceTree = "<group>"; };
DAF3878F1211AF30003DF2B8 /* UITintedGlassButtonShadow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "UITintedGlassButtonShadow@2x.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -171,6 +174,8 @@
DA9AD658138FC3B200BDC968 /* FindSymbol.c */,
DA8BF5B7112EAC4E0044106B /* GlossyButtonViewController.h */,
DA8BF5B8112EAC4E0044106B /* GlossyButtonViewController.m */,
DAD7253D14BB9A7F001ED756 /* NSString+IPAArchive.h */,
DAD7253E14BB9A7F001ED756 /* NSString+IPAArchive.m */,
DAB5332D14B3C38400EDDE37 /* IPAArchive.h */,
DAB5332E14B3C38400EDDE37 /* IPAArchive.m */,
DAB5332F14B3C38400EDDE37 /* IPAViewController.h */,
Expand Down Expand Up @@ -418,6 +423,7 @@
DAB5336F14B3C39D00EDDE37 /* ZKFileArchive.m in Sources */,
DAB5337014B3C39D00EDDE37 /* ZKLFHeader.m in Sources */,
DAB5337114B3C39D00EDDE37 /* ZKLog.m in Sources */,
DAD7253F14BB9A80001ED756 /* NSString+IPAArchive.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit cec8d75

Please sign in to comment.