Cocoa 中的 FNSubscribe 替换
FNSubscribe replacement in Cocoa
我无法在 CarbonCore 框架中找到 "FNSubscribe" 方法的替代方法。此函数用于监视目录的任何更改并在发生更改时执行回调函数。
/*
* FNSubscribe()
*
* Summary:
* Subscribe to change notifications for the specified directory.
*
* Mac OS X threading:
* Thread safe since version 10.1
*
* Parameters:
*
* directoryRef:
* Directory for which the caller wants notifications
*
* callback:
* Function to call back when a notification arrives
*
* refcon:
* User state carried with the subscription
*
* flags:
* Options for future use (specify kNilOptions, or one of the
* FNSubscriptionOptions)
*
* subscription:
* Subscription token for subsequent query or unsubscription
*
* Availability:
* Mac OS X: in version 10.1 and later in CoreServices.framework
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.1 and later
* Non-Carbon CFM: not available
*/
extern OSStatus FNSubscribe(const FSRef *directoryRef, FNSubscriptionUPP callback, void *refcon, OptionBits flags, FNSubscriptionRef *subscription) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
如何使用 Cocoa 并最终 运行 回调函数来监视目录?
从 OS X 10.5 开始,您可以使用 File System Events(又名 FSEvents)API。
我无法在 CarbonCore 框架中找到 "FNSubscribe" 方法的替代方法。此函数用于监视目录的任何更改并在发生更改时执行回调函数。
/*
* FNSubscribe()
*
* Summary:
* Subscribe to change notifications for the specified directory.
*
* Mac OS X threading:
* Thread safe since version 10.1
*
* Parameters:
*
* directoryRef:
* Directory for which the caller wants notifications
*
* callback:
* Function to call back when a notification arrives
*
* refcon:
* User state carried with the subscription
*
* flags:
* Options for future use (specify kNilOptions, or one of the
* FNSubscriptionOptions)
*
* subscription:
* Subscription token for subsequent query or unsubscription
*
* Availability:
* Mac OS X: in version 10.1 and later in CoreServices.framework
* CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.1 and later
* Non-Carbon CFM: not available
*/
extern OSStatus FNSubscribe(const FSRef *directoryRef, FNSubscriptionUPP callback, void *refcon, OptionBits flags, FNSubscriptionRef *subscription) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
如何使用 Cocoa 并最终 运行 回调函数来监视目录?
从 OS X 10.5 开始,您可以使用 File System Events(又名 FSEvents)API。