Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### Xcode ###
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

# End of https://www.gitignore.io/api/xcode

13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
os: osx
osx_image: xcode9.1

language: objective-c

xcode_project: iMeme.xcodeproj
xcode_scheme: iMeme

# https://stackoverflow.com/questions/41786984/error-unexpected-action-build-when-building-a-project-with-swift-3-and-cocoa
# prevents 'ERROR: Unexpected action: build'
script:
- xcodebuild clean build -sdk iphonesimulator -workspace Project.xcworkspace -scheme ProjectTests CODE_SIGNING_REQUIRED=NO

93 changes: 93 additions & 0 deletions iMeme.xcodeproj/xcshareddata/xcschemes/iMeme.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69C2ECCC147EE60A00EC7161"
BuildableName = "iMeme.app"
BlueprintName = "iMeme"
ReferencedContainer = "container:iMeme.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69C2ECCC147EE60A00EC7161"
BuildableName = "iMeme.app"
BlueprintName = "iMeme"
ReferencedContainer = "container:iMeme.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69C2ECCC147EE60A00EC7161"
BuildableName = "iMeme.app"
BlueprintName = "iMeme"
ReferencedContainer = "container:iMeme.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "69C2ECCC147EE60A00EC7161"
BuildableName = "iMeme.app"
BlueprintName = "iMeme"
ReferencedContainer = "container:iMeme.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
5 changes: 4 additions & 1 deletion iMeme/TableViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
#import "AppDelegate.h"

@interface TableViewController : NSObject <NSTableViewDataSource, NSTableViewDelegate> {
NSMutableArray* items;
NSMutableArray* allItems;
NSArray* filteredItems;
AppDelegate* appDelegate;
NSTableView* tableView;
NSSearchField *searchField;
}

@property (assign) IBOutlet NSSearchField *searchField;
@property (assign) IBOutlet AppDelegate* appDelegate;
@property (assign) IBOutlet NSTableView* tableView;

Expand Down
23 changes: 18 additions & 5 deletions iMeme/TableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,53 @@

@implementation TableViewController

@synthesize searchField;
@synthesize appDelegate;
@synthesize tableView;

- (id)init {
self = [super init];
if (self) {
items = [[NSMutableArray alloc] init];
allItems = [[NSMutableArray alloc] init];
NSArray* paths = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:nil];
for (NSString* filename in paths) {
NSString* path = [[filename lastPathComponent] stringByDeletingPathExtension];
NSString* name = [path stringByReplacingOccurrencesOfString:@"-" withString:@" "];
path = [[NSBundle mainBundle] pathForImageResource:path];
[items addObject:[[Template alloc] initWithName:name path:path]];
[allItems addObject:[[Template alloc] initWithName:name path:path]];
}
filteredItems = allItems.copy;
}
return self;
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
return [items count];
return [filteredItems count];
}

- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
Template* template = [items objectAtIndex:row];
Template* template = [filteredItems objectAtIndex:row];
NSString* identifier = [tableColumn identifier];
return [template valueForKey:identifier];
}

- (void)tableViewSelectionDidChange:(NSNotification *)notification {
NSInteger row = [tableView selectedRow];
if (row >= 0) {
Template* template = [items objectAtIndex:row];
Template* template = [filteredItems objectAtIndex:row];
[appDelegate setPath:[template path]];
}
}

- (IBAction)updateFilter:(id)sender {
NSString *filter = [self.searchField stringValue];
if (filter.length > 0) {
NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"self.name CONTAINS[cd] %@", filter];
filteredItems = [[allItems filteredArrayUsingPredicate:filterPredicate] mutableCopy];
} else {
filteredItems = allItems.copy;
}
[self.tableView reloadData];
}

@end
Loading