In XCTest with swift you can define mock objects in the test function you need it in. Like so
func testFunction(){
    class mockClass: AnyObject{
        func aFunction(){
        }
    }
}
I'm trying to use these mock objects to test that another function sends out the correct notification given a certain condition (in my case that the success notification is broadcast with a 204 status code to an object.
The problem I am having is that i get an "Unrecognised selector" runtime error even though the deletedSuccess() function is clearly there/
Heres some code dump
func testDelete(){
    let expectation = expectationWithDescription("Post was deleted")
    class MockReciever : AnyObject {
        func deleteSuccess(){
            println("delete successfull")
            expectation.fulfill()
        }
    }
    let mockReciever = MockReciever()
    NSNotificationCenter.defaultCenter().addObserver(mockReciever, selector: "deleteSuccess", name: PostDeletedNotification, object: post)
    let response = NSHTTPURLResponse(URL: NSURL(), statusCode: 204, HTTPVersion: nil, headerFields: nil)
    let request = NSURLRequest()
    post.deleteCompletion(request, response: response, data: nil, error: nil)
    waitForExpectationsWithTimeout(30, handler: { (error) -> Void in
        if error != nil{
            XCTFail("Did not recieve success notification")
        } else {
            XCTAssertTrue(true, "post deleted successfully")
        }
        NSNotificationCenter.defaultCenter().removeObserver(mockReciever)
    })
}
Is there some sort of problem with using mock objects and selectors like this that I don't know about?
 
     
    