Cocoa 中的 FNSubscribe 替换
Posted
技术标签:
【中文标题】Cocoa 中的 FNSubscribe 替换【英文标题】:FNSubscribe replacement in Cocoa 【发布时间】:2016-11-17 12:42:44 【问题描述】:我无法在 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 观察目录并最终运行回调函数?
【问题讨论】:
【参考方案1】:从 OS X 10.5 开始,您可以使用 File System Events(又名 FSEvents)API。
【讨论】:
以上是关于Cocoa 中的 FNSubscribe 替换的主要内容,如果未能解决你的问题,请参考以下文章