你可以用自己的版本,返回版本衝突的數組補丁+unresolvedConflictVersionsOfItemAtURL
:
#import <objc/runtime.h>
static IMP __originalUnresolvedConflictVersionIMP = NULL ;
static NSArray * MyNSFileVersionUnresolvedConflictVersions(id self, SEL _cmd, NSURL * url)
{
// this code just calls the original implementation...
// You can return an array of conflicting NSFileVersion objects instead...
NSLog(@"%s called\n", __PRETTY_FUNCTION__) ;
return (*__originalUnresolvedConflictVersionIMP)(self, _cmd, url) ;
}
@implementation NSFileVersion (Test)
+(void)load
{
__originalUnresolvedConflictVersionIMP = class_replaceMethod(objc_getMetaClass("NSFileVersion") , @selector(unresolvedConflictVersionsOfItemAtURL:), (IMP)MyNSFileVersionUnresolvedConflictVersions, "@@:@") ;
}
@end
這就夠了去?我可能會首先嚐試在我的替換「方法」:
return [ [ self otherVersionsOfItemAtURL:url ] lastObject ] ;
似乎沒有公開的方式。我現在已經提交了一個雷達:[rdar:// 12196293](http://openradar.appspot.com/12196293)。任何*黑客建議*仍將不勝感激。 –