Skip to content

Commit d85c475

Browse files
committed
Support Swift 2.2
1 parent 4659e52 commit d85c475

File tree

89 files changed

+578
-546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+578
-546
lines changed

Centipede.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 = "Centipede"
3-
s.version = "1.1.0"
3+
s.version = "1.2.0"
44
s.summary = "Swift achieve a pure library closures achieve UIKit assembly delegate and dataSource methods."
55
s.description = <<-DESC
66
一个Swift库,使用闭包实现UIKit组件的delegate和dataSource方法

Centipede/AVFoundation/CE_AVAudioPlayer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ internal class AVAudioPlayer_Delegate: NSObject, AVAudioPlayerDelegate {
7474
override func respondsToSelector(aSelector: Selector) -> Bool {
7575

7676
let funcDic1: [Selector : Any?] = [
77-
"audioPlayerDidFinishPlaying:successfully:" : _didFinishPlaying,
78-
"audioPlayerDecodeErrorDidOccur:error:" : _decodeErrorDidOccur,
79-
"audioPlayerBeginInterruption:" : _beginInterruption,
80-
"audioPlayerEndInterruption:withOptions:" : _endInterruption,
77+
#selector(audioPlayerDidFinishPlaying(_:successfully:)) : _didFinishPlaying,
78+
#selector(audioPlayerDecodeErrorDidOccur(_:error:)) : _decodeErrorDidOccur,
79+
#selector(audioPlayerBeginInterruption(_:)) : _beginInterruption,
80+
#selector(audioPlayerEndInterruption(_:withOptions:)) : _endInterruption,
8181
]
8282
if let f = funcDic1[aSelector] {
8383
return f != nil

Centipede/AVFoundation/CE_AVAudioRecorder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ internal class AVAudioRecorder_Delegate: NSObject, AVAudioRecorderDelegate {
7474
override func respondsToSelector(aSelector: Selector) -> Bool {
7575

7676
let funcDic1: [Selector : Any?] = [
77-
"audioRecorderDidFinishRecording:successfully:" : _didFinishRecording,
78-
"audioRecorderEncodeErrorDidOccur:error:" : _encodeErrorDidOccur,
79-
"audioRecorderBeginInterruption:" : _beginInterruption,
80-
"audioRecorderEndInterruption:withOptions:" : _endInterruption,
77+
#selector(audioRecorderDidFinishRecording(_:successfully:)) : _didFinishRecording,
78+
#selector(audioRecorderEncodeErrorDidOccur(_:error:)) : _encodeErrorDidOccur,
79+
#selector(audioRecorderBeginInterruption(_:)) : _beginInterruption,
80+
#selector(audioRecorderEndInterruption(_:withOptions:)) : _endInterruption,
8181
]
8282
if let f = funcDic1[aSelector] {
8383
return f != nil

Centipede/AVFoundation/CE_AVSpeechSynthesizer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ internal class AVSpeechSynthesizer_Delegate: NSObject, AVSpeechSynthesizerDelega
8686
override func respondsToSelector(aSelector: Selector) -> Bool {
8787

8888
let funcDic1: [Selector : Any?] = [
89-
"speechSynthesizer:didStartSpeechUtterance:" : _didStartSpeechUtterance,
90-
"speechSynthesizer:didFinishSpeechUtterance:" : _didFinishSpeechUtterance,
91-
"speechSynthesizer:didPauseSpeechUtterance:" : _didPauseSpeechUtterance,
92-
"speechSynthesizer:didContinueSpeechUtterance:" : _didContinueSpeechUtterance,
93-
"speechSynthesizer:didCancelSpeechUtterance:" : _didCancelSpeechUtterance,
94-
"speechSynthesizer:willSpeakRangeOfSpeechString:utterance:" : _willSpeakRangeOfSpeechString,
89+
#selector(speechSynthesizer(_:didStartSpeechUtterance:)) : _didStartSpeechUtterance,
90+
#selector(speechSynthesizer(_:didFinishSpeechUtterance:)) : _didFinishSpeechUtterance,
91+
#selector(speechSynthesizer(_:didPauseSpeechUtterance:)) : _didPauseSpeechUtterance,
92+
#selector(speechSynthesizer(_:didContinueSpeechUtterance:)) : _didContinueSpeechUtterance,
93+
#selector(speechSynthesizer(_:didCancelSpeechUtterance:)) : _didCancelSpeechUtterance,
94+
#selector(speechSynthesizer(_:willSpeakRangeOfSpeechString:utterance:)) : _willSpeakRangeOfSpeechString,
9595
]
9696
if let f = funcDic1[aSelector] {
9797
return f != nil

Centipede/CoreBluetooth/CE_CBCentralManager.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,20 @@ internal class CBCentralManager_Delegate: NSObject, CBCentralManagerDelegate {
9898
override func respondsToSelector(aSelector: Selector) -> Bool {
9999

100100
let funcDic1: [Selector : Any?] = [
101-
"centralManagerDidUpdateState:" : _didUpdateState,
102-
"centralManager:willRestoreState:" : _willRestoreState,
103-
"centralManager:didRetrievePeripherals:" : _didRetrievePeripherals,
104-
"centralManager:didRetrieveConnectedPeripherals:" : _didRetrieveConnectedPeripherals,
105-
"centralManager:didDiscoverPeripheral:advertisementData:RSSI:" : _didDiscoverPeripheral,
106-
"centralManager:didConnectPeripheral:" : _didConnectPeripheral,
107-
"centralManager:didFailToConnectPeripheral:error:" : _didFailToConnectPeripheral,
101+
#selector(centralManagerDidUpdateState(_:)) : _didUpdateState,
102+
#selector(centralManager(_:willRestoreState:)) : _willRestoreState,
103+
#selector(centralManager(_:didRetrievePeripherals:)) : _didRetrievePeripherals,
104+
#selector(centralManager(_:didRetrieveConnectedPeripherals:)) : _didRetrieveConnectedPeripherals,
105+
#selector(centralManager(_:didDiscoverPeripheral:advertisementData:RSSI:)) : _didDiscoverPeripheral,
106+
#selector(centralManager(_:didConnectPeripheral:)) : _didConnectPeripheral,
107+
#selector(centralManager(_:didFailToConnectPeripheral:error:)) : _didFailToConnectPeripheral,
108108
]
109109
if let f = funcDic1[aSelector] {
110110
return f != nil
111111
}
112112

113113
let funcDic2: [Selector : Any?] = [
114-
"centralManager:didDisconnectPeripheral:error:" : _didDisconnectPeripheral,
114+
#selector(centralManager(_:didDisconnectPeripheral:error:)) : _didDisconnectPeripheral,
115115
]
116116
if let f = funcDic2[aSelector] {
117117
return f != nil

Centipede/CoreBluetooth/CE_CBPeripheral.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,25 @@ internal class CBPeripheral_Delegate: NSObject, CBPeripheralDelegate {
128128
override func respondsToSelector(aSelector: Selector) -> Bool {
129129

130130
let funcDic1: [Selector : Any?] = [
131-
"peripheralDidUpdateName:" : _didUpdateName,
132-
"peripheral:didModifyServices:" : _didModifyServices,
133-
"peripheralDidUpdateRSSI:error:" : _didUpdateRSSI,
134-
"peripheral:didReadRSSI:error:" : _didReadRSSI,
135-
"peripheral:didDiscoverServices:" : _didDiscoverServices,
136-
"peripheral:didDiscoverIncludedServicesForService:error:" : _didDiscoverIncludedServicesForService,
137-
"peripheral:didDiscoverCharacteristicsForService:error:" : _didDiscoverCharacteristicsForService,
131+
#selector(peripheralDidUpdateName(_:)) : _didUpdateName,
132+
#selector(peripheral(_:didModifyServices:)) : _didModifyServices,
133+
#selector(peripheralDidUpdateRSSI(_:error:)) : _didUpdateRSSI,
134+
#selector(peripheral(_:didReadRSSI:error:)) : _didReadRSSI,
135+
#selector(peripheral(_:didDiscoverServices:)) : _didDiscoverServices,
136+
#selector(peripheral(_:didDiscoverIncludedServicesForService:error:)) : _didDiscoverIncludedServicesForService,
137+
#selector(peripheral(_:didDiscoverCharacteristicsForService:error:)) : _didDiscoverCharacteristicsForService,
138138
]
139139
if let f = funcDic1[aSelector] {
140140
return f != nil
141141
}
142142

143143
let funcDic2: [Selector : Any?] = [
144-
"peripheral:didUpdateValueForCharacteristic:error:" : _didUpdateValueForCharacteristic,
145-
"peripheral:didWriteValueForCharacteristic:error:" : _didWriteValueForCharacteristic,
146-
"peripheral:didUpdateNotificationStateForCharacteristic:error:" : _didUpdateNotificationStateForCharacteristic,
147-
"peripheral:didDiscoverDescriptorsForCharacteristic:error:" : _didDiscoverDescriptorsForCharacteristic,
148-
"peripheral:didUpdateValueForDescriptor:error:" : _didUpdateValueForDescriptor,
149-
"peripheral:didWriteValueForDescriptor:error:" : _didWriteValueForDescriptor,
144+
#selector(peripheral(_:didUpdateValueForCharacteristic:error:)) : _didUpdateValueForCharacteristic,
145+
#selector(peripheral(_:didWriteValueForCharacteristic:error:)) : _didWriteValueForCharacteristic,
146+
#selector(peripheral(_:didUpdateNotificationStateForCharacteristic:error:)) : _didUpdateNotificationStateForCharacteristic,
147+
#selector(peripheral(_:didDiscoverDescriptorsForCharacteristic:error:)) : _didDiscoverDescriptorsForCharacteristic,
148+
#selector(peripheral(_:didUpdateValueForDescriptor:error:)) : _didUpdateValueForDescriptor,
149+
#selector(peripheral(_:didWriteValueForDescriptor:error:)) : _didWriteValueForDescriptor,
150150
]
151151
if let f = funcDic2[aSelector] {
152152
return f != nil

Centipede/CoreBluetooth/CE_CBPeripheralManager.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,21 @@ internal class CBPeripheralManager_Delegate: NSObject, CBPeripheralManagerDelega
104104
override func respondsToSelector(aSelector: Selector) -> Bool {
105105

106106
let funcDic1: [Selector : Any?] = [
107-
"peripheralManagerDidUpdateState:" : _didUpdateState,
108-
"peripheralManager:willRestoreState:" : _willRestoreState,
109-
"peripheralManagerDidStartAdvertising:error:" : _didStartAdvertising,
110-
"peripheralManager:didAddService:error:" : _didAddService,
111-
"peripheralManager:central:didSubscribeToCharacteristic:" : _centralDidSubscribeToCharacteristic,
112-
"peripheralManager:central:didUnsubscribeFromCharacteristic:" : _centralDidUnsubscribeFromCharacteristic,
113-
"peripheralManager:didReceiveReadRequest:" : _didReceiveReadRequest,
107+
#selector(peripheralManagerDidUpdateState(_:)) : _didUpdateState,
108+
#selector(peripheralManager(_:willRestoreState:)) : _willRestoreState,
109+
#selector(peripheralManagerDidStartAdvertising(_:error:)) : _didStartAdvertising,
110+
#selector(peripheralManager(_:didAddService:error:)) : _didAddService,
111+
#selector(peripheralManager(_:central:didSubscribeToCharacteristic:)) : _centralDidSubscribeToCharacteristic,
112+
#selector(peripheralManager(_:central:didUnsubscribeFromCharacteristic:)) : _centralDidUnsubscribeFromCharacteristic,
113+
#selector(peripheralManager(_:didReceiveReadRequest:)) : _didReceiveReadRequest,
114114
]
115115
if let f = funcDic1[aSelector] {
116116
return f != nil
117117
}
118118

119119
let funcDic2: [Selector : Any?] = [
120-
"peripheralManager:didReceiveWriteRequests:" : _didReceiveWriteRequests,
121-
"peripheralManagerIsReadyToUpdateSubscribers:" : _isReadyToUpdateSubscribers,
120+
#selector(peripheralManager(_:didReceiveWriteRequests:)) : _didReceiveWriteRequests,
121+
#selector(peripheralManagerIsReadyToUpdateSubscribers(_:)) : _isReadyToUpdateSubscribers,
122122
]
123123
if let f = funcDic2[aSelector] {
124124
return f != nil

Centipede/CoreData/CE_NSFetchedResultsController.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ internal class NSFetchedResultsController_Delegate: NSObject, NSFetchedResultsCo
8080
override func respondsToSelector(aSelector: Selector) -> Bool {
8181

8282
let funcDic1: [Selector : Any?] = [
83-
"controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:" : _controller,
84-
"controller:didChangeSection:atIndex:forChangeType:" : _controllerAndDidChangeSection,
85-
"controllerWillChangeContent:" : _controllerWillChangeContent,
86-
"controllerDidChangeContent:" : _controllerDidChangeContent,
87-
"controller:sectionIndexTitleForSectionName:" : _controllerAndSectionIndexTitleForSectionName,
83+
#selector(controller(_:didChangeObject:atIndexPath:forChangeType:newIndexPath:)) : _controller,
84+
#selector(controller(_:didChangeSection:atIndex:forChangeType:)) : _controllerAndDidChangeSection,
85+
#selector(controllerWillChangeContent(_:)) : _controllerWillChangeContent,
86+
#selector(controllerDidChangeContent(_:)) : _controllerDidChangeContent,
87+
#selector(controller(_:sectionIndexTitleForSectionName:)) : _controllerAndSectionIndexTitleForSectionName,
8888
]
8989
if let f = funcDic1[aSelector] {
9090
return f != nil

Centipede/CoreLocation/CE_CLLocationManager.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,34 +146,34 @@ internal class CLLocationManager_Delegate: NSObject, CLLocationManagerDelegate {
146146
override func respondsToSelector(aSelector: Selector) -> Bool {
147147

148148
let funcDic1: [Selector : Any?] = [
149-
"locationManager:didUpdateLocations:" : _didUpdateLocations,
150-
"locationManager:didUpdateHeading:" : _didUpdateHeading,
151-
"locationManagerShouldDisplayHeadingCalibration:" : _shouldDisplayHeadingCalibration,
152-
"locationManager:didDetermineState:forRegion:" : _didDetermineState,
153-
"locationManager:didRangeBeacons:inRegion:" : _didRangeBeacons,
154-
"locationManager:rangingBeaconsDidFailForRegion:withError:" : _rangingBeaconsDidFailForRegion,
155-
"locationManager:didEnterRegion:" : _didEnterRegion,
149+
#selector(locationManager(_:didUpdateLocations:)) : _didUpdateLocations,
150+
#selector(locationManager(_:didUpdateHeading:)) : _didUpdateHeading,
151+
#selector(locationManagerShouldDisplayHeadingCalibration(_:)) : _shouldDisplayHeadingCalibration,
152+
#selector(locationManager(_:didDetermineState:forRegion:)) : _didDetermineState,
153+
#selector(locationManager(_:didRangeBeacons:inRegion:)) : _didRangeBeacons,
154+
#selector(locationManager(_:rangingBeaconsDidFailForRegion:withError:)) : _rangingBeaconsDidFailForRegion,
155+
#selector(locationManager(_:didEnterRegion:)) : _didEnterRegion,
156156
]
157157
if let f = funcDic1[aSelector] {
158158
return f != nil
159159
}
160160

161161
let funcDic2: [Selector : Any?] = [
162-
"locationManager:didExitRegion:" : _didExitRegion,
163-
"locationManager:didFailWithError:" : _didFailWithError,
164-
"locationManager:monitoringDidFailForRegion:withError:" : _monitoringDidFailForRegion,
165-
"locationManager:didChangeAuthorizationStatus:" : _didChangeAuthorizationStatus,
166-
"locationManager:didStartMonitoringForRegion:" : _didStartMonitoringForRegion,
167-
"locationManagerDidPauseLocationUpdates:" : _didPauseLocationUpdates,
168-
"locationManagerDidResumeLocationUpdates:" : _didResumeLocationUpdates,
162+
#selector(locationManager(_:didExitRegion:)) : _didExitRegion,
163+
#selector(locationManager(_:didFailWithError:)) : _didFailWithError,
164+
#selector(locationManager(_:monitoringDidFailForRegion:withError:)) : _monitoringDidFailForRegion,
165+
#selector(locationManager(_:didChangeAuthorizationStatus:)) : _didChangeAuthorizationStatus,
166+
#selector(locationManager(_:didStartMonitoringForRegion:)) : _didStartMonitoringForRegion,
167+
#selector(locationManagerDidPauseLocationUpdates(_:)) : _didPauseLocationUpdates,
168+
#selector(locationManagerDidResumeLocationUpdates(_:)) : _didResumeLocationUpdates,
169169
]
170170
if let f = funcDic2[aSelector] {
171171
return f != nil
172172
}
173173

174174
let funcDic3: [Selector : Any?] = [
175-
"locationManager:didFinishDeferredUpdatesWithError:" : _didFinishDeferredUpdatesWithError,
176-
"locationManager:didVisit:" : _didVisit,
175+
#selector(locationManager(_:didFinishDeferredUpdatesWithError:)) : _didFinishDeferredUpdatesWithError,
176+
#selector(locationManager(_:didVisit:)) : _didVisit,
177177
]
178178
if let f = funcDic3[aSelector] {
179179
return f != nil

Centipede/EventKitUI/CE_EKCalendarChooser.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ internal class EKCalendarChooser_Delegate: UIViewController_Delegate, EKCalendar
6868
override func respondsToSelector(aSelector: Selector) -> Bool {
6969

7070
let funcDic1: [Selector : Any?] = [
71-
"calendarChooserSelectionDidChange:" : _selectionDidChange,
72-
"calendarChooserDidFinish:" : _didFinish,
73-
"calendarChooserDidCancel:" : _didCancel,
71+
#selector(calendarChooserSelectionDidChange(_:)) : _selectionDidChange,
72+
#selector(calendarChooserDidFinish(_:)) : _didFinish,
73+
#selector(calendarChooserDidCancel(_:)) : _didCancel,
7474
]
7575
if let f = funcDic1[aSelector] {
7676
return f != nil

0 commit comments

Comments
 (0)