Skip to content

Commit ac6edd1

Browse files
authored
Merge pull request #92 from nohana/Xcode9
Xcode9/Swift4
2 parents 753332e + e067d8c commit ac6edd1

14 files changed

+86
-67
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

Demo/Base.lproj/Main.storyboard

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="q5W-GZ-eHb">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="q5W-GZ-eHb">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
47
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
610
</dependencies>
711
<scenes>
812
<!--NohanaImagePicker-->
913
<scene sceneID="HUA-ek-SMk">
1014
<objects>
1115
<tableViewController id="G3T-A5-GIu" customClass="DemoListViewController" customModule="Demo" customModuleProvider="target" sceneMemberID="viewController">
1216
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="LNK-dE-8Ye">
13-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
17+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1418
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
15-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
19+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
1620
<prototypes>
1721
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="lwK-uA-3Me" style="IBUITableViewCellStyleDefault" id="6f6-ob-xNw">
18-
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
22+
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
1923
<autoresizingMask key="autoresizingMask"/>
2024
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="6f6-ob-xNw" id="VH4-Rk-3Uo">
21-
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
25+
<rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/>
2226
<autoresizingMask key="autoresizingMask"/>
2327
<subviews>
2428
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="lwK-uA-3Me">
25-
<rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
29+
<rect key="frame" x="16" y="0.0" width="344" height="43.5"/>
2630
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2731
<fontDescription key="fontDescription" type="system" pointSize="16"/>
28-
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
32+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2933
<nil key="highlightedColor"/>
3034
</label>
3135
</subviews>
@@ -49,7 +53,7 @@
4953
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="q5W-GZ-eHb" sceneMemberID="viewController">
5054
<toolbarItems/>
5155
<navigationBar key="navigationBar" contentMode="scaleToFill" id="RTV-gX-iYb">
52-
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
56+
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
5357
<autoresizingMask key="autoresizingMask"/>
5458
</navigationBar>
5559
<nil name="viewControllers"/>

Demo/DemoListViewController.swift

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
7373
switch PHPhotoLibrary.authorizationStatus() {
7474
case .notDetermined:
7575
PHPhotoLibrary.requestAuthorization { status in
76-
switch status {
77-
case .authorized:
78-
handler(true)
79-
default:
80-
handler(false)
76+
DispatchQueue.main.async {
77+
switch status {
78+
case .authorized:
79+
handler(true)
80+
default:
81+
handler(false)
82+
}
8183
}
8284
}
83-
8485
case .restricted:
8586
handler(false)
8687
case .denied:
@@ -92,32 +93,28 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
9293

9394
// MARK: - Show NohanaImagePicker
9495

95-
@objc
96-
func showDefaultPicker() {
96+
@objc func showDefaultPicker() {
9797
let picker = NohanaImagePickerController()
9898
picker.delegate = self
9999
present(picker, animated: true, completion: nil)
100100
}
101101

102-
@objc
103-
func showLargeThumbnailPicker() {
102+
@objc func showLargeThumbnailPicker() {
104103
let picker = NohanaImagePickerController()
105104
picker.delegate = self
106105
picker.numberOfColumnsInPortrait = 2
107106
picker.numberOfColumnsInLandscape = 3
108107
present(picker, animated: true, completion: nil)
109108
}
110109

111-
@objc
112-
func showNoToolbarPicker() {
110+
@objc func showNoToolbarPicker() {
113111
let picker = NohanaImagePickerController()
114112
picker.delegate = self
115113
picker.toolbarHidden = true
116114
present(picker, animated: true, completion: nil)
117115
}
118116

119-
@objc
120-
func showDisableToPickAssetsPicker() {
117+
@objc func showDisableToPickAssetsPicker() {
121118
let picker = NohanaImagePickerController()
122119
picker.delegate = self
123120
picker.canPickAsset = { (asset: Asset) -> Bool in
@@ -126,8 +123,7 @@ class DemoListViewController: UITableViewController, NohanaImagePickerController
126123
present(picker, animated: true, completion: nil)
127124
}
128125

129-
@objc
130-
func showCustomUIPicker() {
126+
@objc func showCustomUIPicker() {
131127
let picker = NohanaImagePickerController()
132128
picker.delegate = self
133129
picker.config.color.background = UIColor(red: 0xcc/0xff, green: 0xff/0xff, blue: 0xff/0xff, alpha: 1)

NohanaImagePicker.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'NohanaImagePicker'
3-
s.version = '0.8.0'
3+
s.version = '0.9.0'
44
s.summary = 'A multiple image picker for iOS app.'
55
s.homepage = 'https://github.com/nohana/NohanaImagePicker'
66
s.license = { :type => 'Apache License v2', :file => 'LICENSE' }

NohanaImagePicker.xcodeproj/project.pbxproj

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,16 @@
313313
isa = PBXProject;
314314
attributes = {
315315
LastSwiftUpdateCheck = 0720;
316-
LastUpgradeCheck = 0800;
316+
LastUpgradeCheck = 0900;
317317
ORGANIZATIONNAME = nohana;
318318
TargetAttributes = {
319319
F208E5501CD7370B00FFC9F6 = {
320320
CreatedOnToolsVersion = 7.2.1;
321-
LastSwiftMigration = 0800;
321+
LastSwiftMigration = 0900;
322322
};
323323
F2C08D731C68651900B00181 = {
324324
CreatedOnToolsVersion = 7.2.1;
325-
LastSwiftMigration = 0800;
325+
LastSwiftMigration = 0900;
326326
};
327327
};
328328
};
@@ -462,7 +462,8 @@
462462
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
463463
PRODUCT_BUNDLE_IDENTIFIER = jp.co.nohana.NohanaImagePicker.Demo;
464464
PRODUCT_NAME = "$(TARGET_NAME)";
465-
SWIFT_VERSION = 3.0;
465+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
466+
SWIFT_VERSION = 4.0;
466467
};
467468
name = Debug;
468469
};
@@ -476,7 +477,8 @@
476477
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
477478
PRODUCT_BUNDLE_IDENTIFIER = jp.co.nohana.NohanaImagePicker.Demo;
478479
PRODUCT_NAME = "$(TARGET_NAME)";
479-
SWIFT_VERSION = 3.0;
480+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
481+
SWIFT_VERSION = 4.0;
480482
};
481483
name = Release;
482484
};
@@ -489,14 +491,20 @@
489491
CLANG_CXX_LIBRARY = "libc++";
490492
CLANG_ENABLE_MODULES = YES;
491493
CLANG_ENABLE_OBJC_ARC = YES;
494+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
492495
CLANG_WARN_BOOL_CONVERSION = YES;
496+
CLANG_WARN_COMMA = YES;
493497
CLANG_WARN_CONSTANT_CONVERSION = YES;
494498
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
495499
CLANG_WARN_EMPTY_BODY = YES;
496500
CLANG_WARN_ENUM_CONVERSION = YES;
497501
CLANG_WARN_INFINITE_RECURSION = YES;
498502
CLANG_WARN_INT_CONVERSION = YES;
503+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
504+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
499505
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
506+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
507+
CLANG_WARN_STRICT_PROTOTYPES = YES;
500508
CLANG_WARN_SUSPICIOUS_MOVE = YES;
501509
CLANG_WARN_UNREACHABLE_CODE = YES;
502510
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -541,14 +549,20 @@
541549
CLANG_CXX_LIBRARY = "libc++";
542550
CLANG_ENABLE_MODULES = YES;
543551
CLANG_ENABLE_OBJC_ARC = YES;
552+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
544553
CLANG_WARN_BOOL_CONVERSION = YES;
554+
CLANG_WARN_COMMA = YES;
545555
CLANG_WARN_CONSTANT_CONVERSION = YES;
546556
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
547557
CLANG_WARN_EMPTY_BODY = YES;
548558
CLANG_WARN_ENUM_CONVERSION = YES;
549559
CLANG_WARN_INFINITE_RECURSION = YES;
550560
CLANG_WARN_INT_CONVERSION = YES;
561+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
562+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
551563
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
564+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
565+
CLANG_WARN_STRICT_PROTOTYPES = YES;
552566
CLANG_WARN_SUSPICIOUS_MOVE = YES;
553567
CLANG_WARN_UNREACHABLE_CODE = YES;
554568
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -595,7 +609,8 @@
595609
PRODUCT_NAME = "$(TARGET_NAME)";
596610
SKIP_INSTALL = YES;
597611
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
598-
SWIFT_VERSION = 3.0;
612+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
613+
SWIFT_VERSION = 4.0;
599614
};
600615
name = Debug;
601616
};
@@ -615,7 +630,8 @@
615630
PRODUCT_BUNDLE_IDENTIFIER = jp.co.nohana.NohanaImagePicker;
616631
PRODUCT_NAME = "$(TARGET_NAME)";
617632
SKIP_INSTALL = YES;
618-
SWIFT_VERSION = 3.0;
633+
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
634+
SWIFT_VERSION = 4.0;
619635
};
620636
name = Release;
621637
};

NohanaImagePicker.xcodeproj/xcshareddata/xcschemes/NohanaImagePicker.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0800"
3+
LastUpgradeVersion = "0900"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

NohanaImagePicker/AlbumListEmptyIndicator.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ class AlbumListEmptyIndicator: UILabel {
2323
centerStyle.alignment = NSTextAlignment.center
2424

2525
let messageAttributes = [
26-
NSForegroundColorAttributeName : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1),
27-
NSFontAttributeName : UIFont.systemFont(ofSize: 26),
28-
NSParagraphStyleAttributeName : centerStyle
26+
NSAttributedStringKey.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1),
27+
NSAttributedStringKey.font : UIFont.systemFont(ofSize: 26),
28+
NSAttributedStringKey.paragraphStyle : centerStyle
2929
]
3030
let messageText = NSAttributedString(string: message, attributes: messageAttributes)
3131

3232
let descriptionAttributes = [
33-
NSForegroundColorAttributeName : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1),
34-
NSFontAttributeName : UIFont.systemFont(ofSize: 14),
35-
NSParagraphStyleAttributeName : centerStyle
33+
NSAttributedStringKey.foregroundColor : config.color.empty ?? UIColor(red: 0x88/0xff, green: 0x88/0xff, blue: 0x88/0xff, alpha: 1),
34+
NSAttributedStringKey.font : UIFont.systemFont(ofSize: 14),
35+
NSAttributedStringKey.paragraphStyle : centerStyle
3636
]
3737
let descriptionText = NSAttributedString(string: description, attributes: descriptionAttributes)
3838

3939
let attributedText = NSMutableAttributedString()
4040
attributedText.append(messageText)
41-
attributedText.append(NSAttributedString(string: "\n\n", attributes: [NSFontAttributeName : UIFont.systemFont(ofSize: 6)]))
41+
attributedText.append(NSAttributedString(string: "\n\n", attributes: [NSAttributedStringKey.font : UIFont.systemFont(ofSize: 6)]))
4242
attributedText.append(descriptionText)
4343

4444
self.numberOfLines = 0

NohanaImagePicker/AlbumListViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ extension UIViewController {
261261

262262
let infoButton = UIBarButtonItem(title: "", style: .plain, target: nil, action: nil)
263263
infoButton.isEnabled = false
264-
infoButton.setTitleTextAttributes([NSFontAttributeName: UIFont.systemFont(ofSize: 14), NSForegroundColorAttributeName: UIColor.black], for: UIControlState())
264+
infoButton.setTitleTextAttributes([NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14), NSAttributedStringKey.foregroundColor: UIColor.black], for: UIControlState())
265265
self.toolbarItems = [leftSpace, infoButton, rightSpace]
266266
}
267267

@@ -292,14 +292,14 @@ extension UIViewController {
292292
NotificationCenter.default.addObserver(self, selector: #selector(AlbumListViewController.didDropPhotoKitAsset(_:)), name: NotificationInfo.Asset.PhotoKit.didDrop, object: nil)
293293
}
294294

295-
func didPickPhotoKitAsset(_ notification: Notification) {
295+
@objc func didPickPhotoKitAsset(_ notification: Notification) {
296296
guard let picker = notification.object as? NohanaImagePickerController else {
297297
return
298298
}
299299
setToolbarTitle(picker)
300300
}
301301

302-
func didDropPhotoKitAsset(_ notification: Notification) {
302+
@objc func didDropPhotoKitAsset(_ notification: Notification) {
303303
guard let picker = notification.object as? NohanaImagePickerController else {
304304
return
305305
}

NohanaImagePicker/AssetDetailCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class AssetDetailCell: UICollectionViewCell, UIScrollViewDelegate {
5050

5151
// MARK: - Zoom
5252

53-
func didDoubleTap(_ sender: UITapGestureRecognizer) {
53+
@objc func didDoubleTap(_ sender: UITapGestureRecognizer) {
5454
if scrollView.zoomScale < scrollView.maximumZoomScale {
5555
let center = sender.location(in: imageView)
5656
scrollView.zoom(to: zoomRect(center), animated: true)

NohanaImagePicker/AssetDetailListViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class AssetDetailListViewController: AssetListViewController {
151151

152152
// MARK: - UICollectionViewDelegateFlowLayout
153153

154-
override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
154+
override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
155155
return cellSize
156156
}
157157

NohanaImagePicker/AssetListViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import UIKit
1818
import Photos
1919

20-
class AssetListViewController: UICollectionViewController {
20+
class AssetListViewController: UICollectionViewController, UICollectionViewDelegateFlowLayout {
2121

2222
weak var nohanaImagePickerController: NohanaImagePickerController?
2323
var photoKitAssetList: PhotoKitAssetList!
@@ -136,7 +136,7 @@ class AssetListViewController: UICollectionViewController {
136136

137137
// MARK: - UICollectionViewDelegateFlowLayout
138138

139-
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
139+
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
140140
return cellSize
141141
}
142142

NohanaImagePicker/ContractingAnimationController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ContractingAnimationController: NSObject, UIViewControllerAnimatedTransiti
7878
withDuration: transitionDuration(using: transitionContext),
7979
delay: 0,
8080
options: UIViewAnimationOptions(),
81-
animations: { _ in
81+
animations: {
8282
toVC.view.alpha = 1
8383
contractingImageView.frame = Size.contractingAnimationToCellRect(toVC, toCell: toCell)
8484
}) { _ in

0 commit comments

Comments
 (0)