Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #40 from UrbanCompass/ns
Browse files Browse the repository at this point in the history
remove ns
  • Loading branch information
wesbillman authored Dec 21, 2016
2 parents ce5bc11 + 12cc600 commit cb3ed32
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Snail.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
241F15581E03124600DD70A2 /* UIBarButtonItemExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 241F15571E03124600DD70A2 /* UIBarButtonItemExtensions.swift */; };
2421BA721E09801000EA9064 /* UIGestureRecognizerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2421BA711E09801000EA9064 /* UIGestureRecognizerExtensions.swift */; };
2421BA741E0992D400EA9064 /* NotificationCenterExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2421BA731E0992D400EA9064 /* NotificationCenterExtensions.swift */; };
2421BA771E09A78F00EA9064 /* NSNotificationCenterExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2421BA761E09A78F00EA9064 /* NSNotificationCenterExtensions.swift */; };
2421BA771E09A78F00EA9064 /* NotificationCenterExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2421BA761E09A78F00EA9064 /* NotificationCenterExtensions.swift */; };
24FABD561DFEF670005CF84E /* Fail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FABD551DFEF670005CF84E /* Fail.swift */; };
24FABD581DFEF7EC005CF84E /* FailTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FABD571DFEF7EC005CF84E /* FailTests.swift */; };
24FABD5A1DFF0B48005CF84E /* Replay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 24FABD591DFF0B48005CF84E /* Replay.swift */; };
Expand Down Expand Up @@ -43,7 +43,7 @@
241F15571E03124600DD70A2 /* UIBarButtonItemExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIBarButtonItemExtensions.swift; sourceTree = "<group>"; };
2421BA711E09801000EA9064 /* UIGestureRecognizerExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIGestureRecognizerExtensions.swift; sourceTree = "<group>"; };
2421BA731E0992D400EA9064 /* NotificationCenterExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationCenterExtensions.swift; sourceTree = "<group>"; };
2421BA761E09A78F00EA9064 /* NSNotificationCenterExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSNotificationCenterExtensions.swift; path = Extensions/NSNotificationCenterExtensions.swift; sourceTree = "<group>"; };
2421BA761E09A78F00EA9064 /* NotificationCenterExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NotificationCenterExtensions.swift; path = Extensions/NotificationCenterExtensions.swift; sourceTree = "<group>"; };
24FABD551DFEF670005CF84E /* Fail.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Fail.swift; sourceTree = "<group>"; };
24FABD571DFEF7EC005CF84E /* FailTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FailTests.swift; sourceTree = "<group>"; };
24FABD591DFF0B48005CF84E /* Replay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Replay.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,7 +87,7 @@
2421BA751E09A6D500EA9064 /* Extensions */ = {
isa = PBXGroup;
children = (
2421BA761E09A78F00EA9064 /* NSNotificationCenterExtensions.swift */,
2421BA761E09A78F00EA9064 /* NotificationCenterExtensions.swift */,
);
name = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -287,7 +287,7 @@
CBE54E651DFB395A0008DD64 /* ObservableTests.swift in Sources */,
24FABD5C1DFF0BAF005CF84E /* ReplayTests.swift in Sources */,
CBE54E671DFB4F3F0008DD64 /* VariableTests.swift in Sources */,
2421BA771E09A78F00EA9064 /* NSNotificationCenterExtensions.swift in Sources */,
2421BA771E09A78F00EA9064 /* NotificationCenterExtensions.swift in Sources */,
24FABD581DFEF7EC005CF84E /* FailTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
8 changes: 4 additions & 4 deletions Snail/Extensions/NotificationCenterExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import Foundation
extension NotificationCenter {
private static var observableKey = "ObservableKey"

func observableHandler(_ notification: NSNotification) {
if let observable = objc_getAssociatedObject(self, &NotificationCenter.observableKey) as? Observable<NSNotification> {
func observableHandler(_ notification: Notification) {
if let observable = objc_getAssociatedObject(self, &NotificationCenter.observableKey) as? Observable<Notification> {
observable.on(.next(notification))
}
}

public func observeEvent(_ name: NSNotification.Name?) -> Observable<NSNotification> {
let observable = Observable<NSNotification>()
public func observeEvent(_ name: Notification.Name?) -> Observable<Notification> {
let observable = Observable<Notification>()
objc_setAssociatedObject(self, &NotificationCenter.observableKey, observable, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
addObserver(self, selector: #selector(observableHandler(_:)), name: name, object: nil)
return observable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import UIKit
import XCTest
@testable import Snail

class NSNotificationCenterTests: XCTestCase {
class NotificationCenterTests: XCTestCase {
func testNotificaiton() {
let exp = expectation(description: "notification")
let notificationName = NSNotification.Name.UIKeyboardWillShow
var notifcation: NSNotification?
let notificationName = Notification.Name.UIKeyboardWillShow
var notifcation: Notification?
let subject = NotificationCenter.default.observeEvent(notificationName)
subject.subscribe(onNext: { n in
notifcation = n
Expand Down

0 comments on commit cb3ed32

Please sign in to comment.