Skip to content

Commit ee4ec38

Browse files
committed
[#2] More swifty naming
1 parent 4a96405 commit ee4ec38

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

ObjectiveKit.xcodeproj/xcuserdata/marmelroy.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
endingColumnNumber = "9223372036854775807"
7878
startingLineNumber = "39"
7979
endingLineNumber = "39"
80-
landmarkName = "allIvars()"
80+
landmarkName = "ivars()"
8181
landmarkType = "7">
8282
<Locations>
8383
<Location

ObjectiveKit/ObjectiveClass.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class ObjectiveClass <T: NSObject>: ObjectiveKitRuntimeModification {
2727
/// Get all instance variables implemented by the class.
2828
///
2929
/// - Returns: An array of instance variables.
30-
public func allIvars() -> [String] {
30+
public func ivars() -> [String] {
3131
var count: CUnsignedInt = 0
3232
var ivars = [String]()
3333
let ivarList = class_copyIvarList(internalClass, &count)
@@ -46,7 +46,7 @@ public class ObjectiveClass <T: NSObject>: ObjectiveKitRuntimeModification {
4646
/// Get all selectors implemented by the class.
4747
///
4848
/// - Returns: An array of selectors.
49-
public func allSelectors() -> [Selector] {
49+
public func selectors() -> [Selector] {
5050
var count: CUnsignedInt = 0
5151
var selectors = [Selector]()
5252
let methodList = class_copyMethodList(internalClass, &count)
@@ -63,7 +63,7 @@ public class ObjectiveClass <T: NSObject>: ObjectiveKitRuntimeModification {
6363
/// Get all protocols implemented by the class.
6464
///
6565
/// - Returns: An array of protocol names.
66-
public func allProtocols() -> [String] {
66+
public func protocols() -> [String] {
6767
var count: CUnsignedInt = 0
6868
var protocols = [String]()
6969
let protocolList = class_copyProtocolList(internalClass, &count)
@@ -80,7 +80,7 @@ public class ObjectiveClass <T: NSObject>: ObjectiveKitRuntimeModification {
8080
/// Get all properties implemented by the class.
8181
///
8282
/// - Returns: An array of property names.
83-
public func allProperties() -> [String] {
83+
public func properties() -> [String] {
8484
var count: CUnsignedInt = 0
8585
var properties = [String]()
8686
let propertyList = class_copyPropertyList(internalClass, &count)

ObjectiveKit/RuntimeClass.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class RuntimeClass: NSObject, ObjectiveKitRuntimeModification {
4343

4444

4545
/// Register class. Required before usage. Happens automatically on allocate.
46-
public func registerClass() {
46+
public func register() {
4747
if registered == false {
4848
registered = true
4949
objc_registerClassPair(internalClass)
@@ -54,7 +54,7 @@ public class RuntimeClass: NSObject, ObjectiveKitRuntimeModification {
5454
///
5555
/// - Returns: Custom class object.
5656
public func allocate() -> NSObject {
57-
self.registerClass()
57+
self.register()
5858
return internalClass.alloc() as! NSObject
5959
}
6060

ObjectiveKit/RuntimeModification.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public protocol ObjectiveKitRuntimeModification {
1919
/// - Parameters:
2020
/// - selector: Selector.
2121
/// - originalClass: Object implementing the selector.
22-
func addSelectorToClass(_ selector: Selector, fromClass originalClass: AnyClass)
22+
func addSelector(_ selector: Selector, from originalClass: AnyClass)
2323

2424
/// Add a custom method to the current class.
2525
///
2626
/// - Parameters:
2727
/// - identifier: Selector name.
2828
/// - implementation: Implementation as a closure.
29-
func addMethodToClass(_ identifier: String, implementation: ImplementationBlock)
29+
func addMethod(_ identifier: String, implementation: ImplementationBlock)
3030

3131
/// Exchange selectors implemented in the current class.
3232
///
@@ -39,15 +39,15 @@ public protocol ObjectiveKitRuntimeModification {
3939

4040
extension ObjectiveKitRuntimeModification {
4141

42-
public func addSelectorToClass(_ selector: Selector, fromClass originalClass: AnyClass) {
42+
public func addSelector(_ selector: Selector, from originalClass: AnyClass) {
4343
guard let method = class_getInstanceMethod(originalClass, selector), let implementation = method_getImplementation(method), let typeEncoding = method_getTypeEncoding(method) else {
4444
return
4545
}
4646
let string = String(cString: typeEncoding)
4747
class_addMethod(internalClass, selector, implementation, string)
4848
}
4949

50-
public func addMethodToClass(_ identifier: String, implementation: ImplementationBlock) {
50+
public func addMethod(_ identifier: String, implementation: ImplementationBlock) {
5151
let blockObject = unsafeBitCast(implementation, to: AnyObject.self)
5252
let implementation = imp_implementationWithBlock(blockObject)
5353
let selector = NSSelectorFromString(identifier)

ObjectiveKitTests/ObjectiveKitTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import MapKit
3333
func testAddClosure() {
3434
let methodExpectation = expectation(description: "Method was called")
3535
let objectiveView = ObjectiveClass<UIView>()
36-
objectiveView.addMethodToClass(closureName, implementation: {
36+
objectiveView.addMethod(closureName, implementation: {
3737
methodExpectation.fulfill()
3838
})
3939
let view = UIView()
@@ -45,7 +45,7 @@ import MapKit
4545
let view = UIView()
4646
XCTAssertFalse(view.responds(to: #selector(testSelector)))
4747
let objectiveView = ObjectiveClass<UIView>()
48-
objectiveView.addSelectorToClass(#selector(testSelector), fromClass: self.classForCoder)
48+
objectiveView.addSelector(#selector(testSelector), from: self.classForCoder)
4949
XCTAssert(view.responds(to: #selector(testSelector)))
5050
}
5151

@@ -59,13 +59,13 @@ import MapKit
5959

6060
func testIntrospection() {
6161
let objectiveView = ObjectiveClass<MKMapView>()
62-
let ivars = objectiveView.allIvars()
62+
let ivars = objectiveView.ivars()
6363
XCTAssert(ivars.contains("_camera"))
64-
let selectors = objectiveView.allSelectors()
64+
let selectors = objectiveView.selectors()
6565
XCTAssert(selectors.contains(NSSelectorFromString("layoutSubviews")))
66-
let protocols = objectiveView.allProtocols()
66+
let protocols = objectiveView.protocols()
6767
XCTAssert(protocols.contains("MKAnnotationManagerDelegate"))
68-
let properties = objectiveView.allProperties()
68+
let properties = objectiveView.properties()
6969
XCTAssert(properties.contains("mapRegion"))
7070
}
7171

0 commit comments

Comments
 (0)