Skip to content

Commit dd08ead

Browse files
committed
TableSearch: Version 1.1, 2014-12-18
Incorporate Swift nullability enhancements with the release of Xcode 6.1.1.
1 parent f297b4d commit dd08ead

23 files changed

+83
-309
lines changed

TableSearch/LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Sample code project: Table Search with UISearchController (Obj-C and Swift)
2-
Version: 1.0
2+
Version: 1.1
33

44
IMPORTANT: This Apple software is supplied to you by Apple
55
Inc. ("Apple") in consideration of your agreement to the following

TableSearch/README.md

+9-20
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,19 @@
1-
Table Search with UISearchController
2-
====================================
1+
# Table Search with UISearchController
32

4-
“Table Search with UISearchController” is an iOS sample application that demonstrates how to use UISearchController.
5-
A search controller manages the presentation of a search bar (in concert with the results view controller’s content).
3+
This sample demonstrates how to use UISearchController. A search controller manages the presentation of a search bar (in concert with the results view controller’s content). It also demonstrates how to use UIStateRestoration to restore the search controller.
64

7-
The Xcode project includes two separate projects to support the following languages: Objective-C and Swift.
5+
## Written in Objective-C and Swift
86

7+
This sample is written in both Objective-C and Swift. Both versions of the sample are at the top level directory of this project in folders named "Objective-C" and "Swift". Both versions of the application have the exact same visual appearance; however, the code and structure may be different depending on the choice of language.
98

10-
===========================================================================
11-
BUILD REQUIREMENTS
9+
## Build
1210

13-
iOS 8.0 SDK or later
11+
Building this sample requires Xcode 6.1.1 and iOS 8.1 SDK
1412

13+
## Runtime
1514

16-
===========================================================================
17-
RUNTIME REQUIREMENTS
18-
19-
iOS 8.0 or later
15+
Running the sample requires iOS 8.0 or later.
2016
Both targets use Storyboards and Automatic Reference Counting (ARC).
2117

2218

23-
========================================================
24-
REVISION HISTORY
25-
26-
1.0 - first version
27-
28-
29-
========================================================
30-
Copyright © 2014 Apple Inc. All rights reserved.
19+
Copyright (C) 2014 Apple Inc. All rights reserved.

TableSearch/TableSearch.obj-c/TableSearch-objc.xcodeproj/project.pbxproj

+2
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
isa = XCBuildConfiguration;
286286
buildSettings = {
287287
ALWAYS_SEARCH_USER_PATHS = NO;
288+
CLANG_ENABLE_MODULES = YES;
288289
CLANG_ENABLE_OBJC_ARC = YES;
289290
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
290291
GCC_C_LANGUAGE_STANDARD = c99;
@@ -302,6 +303,7 @@
302303
isa = XCBuildConfiguration;
303304
buildSettings = {
304305
ALWAYS_SEARCH_USER_PATHS = NO;
306+
CLANG_ENABLE_MODULES = YES;
305307
CLANG_ENABLE_OBJC_ARC = YES;
306308
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
307309
GCC_C_LANGUAGE_STANDARD = c99;

TableSearch/TableSearch.obj-c/TableSearch-objc.xcodeproj/xcuserdata/keith.xcuserdatad/xcschemes/TableSearch.objc.xcscheme

-86
This file was deleted.

TableSearch/TableSearch.obj-c/TableSearch-objc.xcodeproj/xcuserdata/keith.xcuserdatad/xcschemes/xcschememanagement.plist

-22
This file was deleted.

TableSearch/TableSearch.obj-c/TableSearch/APLAppDelegate.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
*/
1010

11-
#import <UIKit/UIKit.h>
11+
@import UIKit;
1212

1313
@interface APLAppDelegate : NSObject <UIApplicationDelegate>
1414

TableSearch/TableSearch.obj-c/TableSearch/APLAppDelegate.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
1414

1515
// load our data source and hand it over to APLMainTableViewController
1616
//
17-
NSArray *productArray = @[[APLProduct productWithType:[APLProduct deviceTypeTitle]
17+
NSArray *products = @[[APLProduct productWithType:[APLProduct deviceTypeTitle]
1818
name:@"iPhone"
1919
year:@2007
2020
price:@599.00],
@@ -57,7 +57,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5757
// we are being store from UIStateRestoration
5858
//
5959
APLMainTableViewController *viewController = (APLMainTableViewController *)navigationController.viewControllers[0];
60-
viewController.products = productArray;
60+
viewController.products = products;
6161

6262
return YES;
6363
}

TableSearch/TableSearch.obj-c/TableSearch/APLBaseTableViewController.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
99
*/
1010

11-
#import <UIKit/UIKit.h>
11+
@import UIKit;
1212

1313
@class APLProduct;
1414

15-
static NSString * const kCellIdentifier = @"cellID";
15+
extern NSString *const kCellIdentifier;
1616

1717
@interface APLBaseTableViewController : UITableViewController
1818

TableSearch/TableSearch.obj-c/TableSearch/APLBaseTableViewController.m

+9-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
#import "APLBaseTableViewController.h"
88
#import "APLProduct.h"
99

10+
NSString *const kCellIdentifier = @"cellID";
11+
NSString *const kTableCellNibName = @"TableCell";
12+
1013
@implementation APLBaseTableViewController
1114

1215
- (void)viewDidLoad {
1316
[super viewDidLoad];
1417

15-
[self.tableView registerNib:[UINib nibWithNibName:@"TableCell" bundle:nil] forCellReuseIdentifier:kCellIdentifier];
18+
// we use a nib which contains the cell's view and this class as the files owner
19+
[self.tableView registerNib:[UINib nibWithNibName:kTableCellNibName bundle:nil] forCellReuseIdentifier:kCellIdentifier];
1620
}
1721

1822
- (void)configureCell:(UITableViewCell *)cell forProduct:(APLProduct *)product {
@@ -21,11 +25,11 @@ - (void)configureCell:(UITableViewCell *)cell forProduct:(APLProduct *)product {
2125
// build the price and year string
2226
// use NSNumberFormatter to get the currency format out of this NSNumber (product.introPrice)
2327
//
24-
NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
25-
[numFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
26-
NSString *priceStr = [numFormatter stringFromNumber:product.introPrice];
28+
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
29+
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
30+
NSString *priceString = [numberFormatter stringFromNumber:product.introPrice];
2731

28-
NSString *detailedStr = [NSString stringWithFormat:@"%@ | %@", priceStr, [product.yearIntroduced stringValue]];
32+
NSString *detailedStr = [NSString stringWithFormat:@"%@ | %@", priceString, [product.yearIntroduced stringValue]];
2933
cell.detailTextLabel.text = detailedStr;
3034
}
3135

TableSearch/TableSearch.obj-c/TableSearch/APLDetailViewController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
*/
1010

11-
#import <UIKit/UIKit.h>
11+
@import UIKit;
1212

1313
@class APLProduct;
1414

TableSearch/TableSearch.obj-c/TableSearch/APLDetailViewController.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ - (void)viewWillAppear:(BOOL)animated {
2525

2626
self.yearLabel.text = [self.product.yearIntroduced stringValue];
2727

28-
NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
29-
[numFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
30-
NSString *priceStr = [numFormatter stringFromNumber:self.product.introPrice];
31-
self.priceLabel.text = priceStr;
28+
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
29+
[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
30+
NSString *priceString = [numberFormatter stringFromNumber:self.product.introPrice];
31+
self.priceLabel.text = priceString;
3232
}
3333

3434
#pragma mark - UIStateRestoration
3535

36-
static NSString *ViewControllerProductKey = @"ViewControllerProductKey";
36+
NSString *const ViewControllerProductKey = @"ViewControllerProductKey";
3737

3838
- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
3939
[super encodeRestorableStateWithCoder:coder];

TableSearch/TableSearch.obj-c/TableSearch/APLMainTableViewController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212

1313
@interface APLMainTableViewController : APLBaseTableViewController
1414

15-
@property (nonatomic, strong) NSArray *products;
15+
@property (nonatomic, copy) NSArray *products;
1616

1717
@end

0 commit comments

Comments
 (0)