mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Remove KVOContext from the Foundation overlay.
We're recommending people just go with a global variable. <rdar://problem/17272837> Swift SVN r18837
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
set(SWIFTFOUNDATION_SOURCES
|
||||
Foundation.swift
|
||||
KVO.swift
|
||||
NSStringAPI.swift
|
||||
Misc.mm
|
||||
)
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// FIXME: Make a nested class of 'NSObject'. Currently symbols
|
||||
// are not being generated during compilation when it is a nested class.
|
||||
class KVOContext {
|
||||
class func fromVoidContext(context: CMutableVoidPointer) -> KVOContext {
|
||||
return reinterpretCast(context.value)
|
||||
}
|
||||
}
|
||||
|
||||
extension NSObject {
|
||||
func removeObserver(observer: NSObject!,
|
||||
forKeyPath keyPath: String!,
|
||||
kvoContext: KVOContext)
|
||||
{
|
||||
let ptr = CMutableVoidPointer(owner: kvoContext,
|
||||
value: reinterpretCast(kvoContext))
|
||||
self.removeObserver(observer,
|
||||
forKeyPath: keyPath,
|
||||
context: ptr)
|
||||
Unmanaged(_private: kvoContext).release()
|
||||
}
|
||||
|
||||
func addObserver(observer: NSObject!,
|
||||
forKeyPath keyPath: String!,
|
||||
options: NSKeyValueObservingOptions,
|
||||
kvoContext: KVOContext)
|
||||
{
|
||||
let ptr = CMutableVoidPointer(owner: kvoContext,
|
||||
value: reinterpretCast(kvoContext))
|
||||
Unmanaged(_private: kvoContext).retain()
|
||||
self.addObserver(observer,
|
||||
forKeyPath: keyPath,
|
||||
options: options,
|
||||
context: ptr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user