我正在尝试了解NSHTTPCookieStorage的内部结构,以便能够使用某些方法来从Safari的Cookie存储中分离出单独的存储,就我所知,这是任何非hacky方式都不可能实现的:
Making WKWebView not share cookies with Safari in OS X
https://devforums.apple.com/message/1115007
我在这里找到头文件:
/System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSHTTPCookieStorage.h
除了实现可能应该在其中之外,这没有给我太多信息
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
我查看该库中的符号名称,但仅发现这些名称提及NSHTTPCookieStorage:
$ nm /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation | grep -i cookiestorage
000000000030cbb5 S $ld$add$os10.5$_OBJC_CLASS_$_NSHTTPCookieStorage
000000000030cbb6 S $ld$add$os10.5$_OBJC_METACLASS_$_NSHTTPCookieStorage
000000000030cbb7 S $ld$add$os10.6$_OBJC_CLASS_$_NSHTTPCookieStorage
000000000030cbb8 S $ld$add$os10.6$_OBJC_METACLASS_$_NSHTTPCookieStorage
000000000030cbb9 S $ld$add$os10.7$_OBJC_CLASS_$_NSHTTPCookieStorage
000000000030cbba S $ld$add$os10.7$_OBJC_METACLASS_$_NSHTTPCookieStorage
000000000030cbbb S $ld$add$os10.8$_OBJC_CLASS_$_NSHTTPCookieStorage
000000000030cbbc S $ld$add$os10.8$_OBJC_METACLASS_$_NSHTTPCookieStorage
000000000030cbbd S $ld$add$os10.9$_OBJC_CLASS_$_NSHTTPCookieStorage
000000000030cbbe S $ld$add$os10.9$_OBJC_METACLASS_$_NSHTTPCookieStorage
I _OBJC_CLASS_$_NSHTTPCookieStorage (indirect for _OBJC_CLASS_$_NSHTTPCookieStorage)
U _OBJC_CLASS_$_NSHTTPCookieStorage
I _OBJC_METACLASS_$_NSHTTPCookieStorage (indirect for _OBJC_METACLASS_$_NSHTTPCookieStorage)
U _OBJC_METACLASS_$_NSHTTPCookieStorage
根本没有方法。在该库的类转储中,可以找到所有提到的“ Cookie”:
# class-dump /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation | grep -i cookie
@interface NSHTTPCookie (NSHTTPCookiePortCoding)
事情开始变得有些绝望,所以我调用了字符串!
$ strings /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation | grep -i cookie
setHTTPShouldHandleCookies:
NSHTTPCookiePortCoding
使用方法转换,我将方法包装在
NSHTTPCookieStorage
的sharedHTTPCookieStorage
周围,然后尝试使用XCode调试器输入该方法,以查看是否至少可以进入该方法的程序集,但是XCode会跳过任何方法即使我告诉它进去也要调用该类的方法。看来该班级还没到。该类在哪里定义?我如何了解其内部?
最佳答案
NSHTTPCookieStorage类在CFNetwork.framework中定义。