ShareKit方法在Lion/Xcode 4.3.1中泛滥成灾? [英] ShareKit method swizzling in Lion / Xcode 4.3.1?
问题描述
我最近使用iOS 5 SDK升级到Lion和Xcode 4.3.1,共享库 ShareKit 是损坏-它为电子邮件处理程序使用了混乱的方法.显然,Apple已被禁止,或至少试图逐步淘汰方法.
I recently upgraded to Lion and Xcode 4.3.1 with the iOS 5 SDK, and the sharing library ShareKit is broken - it used method swizzling for its email handler. Apparently Apple has banned or at least attempted to phase out method swizzling.
ShareKit导入不再存在的文件</usr/include/objc/objc-class.h>
,并定义它自己的方法合并方法SHKSwizzle
.它使用它来更改MFMailComposeViewController
的viewDidDisappear:
方法,如下所示:
ShareKit imports a file </usr/include/objc/objc-class.h>
, which no longer exists, and defines its own method swizzling method SHKSwizzle
. It uses this to alter MFMailComposeViewController
's viewDidDisappear:
method as follows:
SHKSwizzle([MFMailComposeViewController class], @selector(viewDidDisappear:), @selector(SHKviewDidDisappear:));
您认为解决此问题的最佳和最简便的方法是什么?
What do you think is the best and easiest way to work around this?
推荐答案
即使在最新的XCode和iOS SDK上,我也从未遇到过与方法相关的错误.我使用 ShareKit 2.0 .尽管我认为应该避免方法混乱.
I have never experienced method swizzling related errors on even on newest XCode and iOS SDK. I use ShareKit 2.0. Though method swizzling is a thing to be avoided in my opinion.
如果我记不清楚的话,陷入困境的方法是viewDidDisappear.看看它能做什么.在iOS 5上,您可以使用- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
中的完成块来实现相同的目的.
The method swizzled is viewDidDisappear if I remember well. Look what it does. On iOS 5 you can achieve the same using completion block in - (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
.
只需更改在- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
中关闭viewController的方式就足够了.
Just change the way you dismiss the viewController in - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
might be enough.
这只是一个主意,如何摆脱方法的麻烦.
This is just an idea, how you might get rid of method swizzle.
这篇关于ShareKit方法在Lion/Xcode 4.3.1中泛滥成灾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!