我在 Xcode 4.5 和 iOS 6.0 中没有要求的日志消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12547490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Log Messages I didn't asked for in Xcode 4.5 with iOS 6.0
提问by J?rg Kirchhof
since I updated Xcode to Version 4.5 and started building for iOS 6 log messages like this keep appearing:
自从我将 Xcode 更新到 4.5 版并开始为 iOS 6 构建日志以来,像这样的日志消息不断出现:
ADDRESPONSE - ADDING TO MEMORY ONLY
I never asked for that (at least not consciously).
我从来没有要求过(至少不是有意识地)。
What do I need to do to stop these messages ? And what is their origin ?
我需要做什么来阻止这些消息?他们的起源是什么?
回答by Shane MacPhillamy
I'm experiencing the same issue, the message is being issued from the CFNetwork framework, this happens both on device and in the iOS simulator. Specifically running strings on CFNetwork shows:
我遇到了同样的问题,消息是从 CFNetwork 框架发出的,这在设备和 iOS 模拟器中都会发生。具体在 CFNetwork 上运行的字符串显示:
ADDRESPONSE - not adding TO DISK OR MEMORY: %@ ADDRESPONSE - ADDING TO MEMORY ONLY: %@
地址 - 不添加到磁盘或内存:%@ 地址 - 仅添加到内存:%@
My guess is it is being issued by CFCachedURLResponse method.
我的猜测是它是由 CFCachedURLResponse 方法发出的。
An update - with further investigation my problem is caused by the following:
更新 - 经过进一步调查,我的问题是由以下原因引起的:
NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity: memoryCapacity diskCapacity: discCapacity diskPath:[SDURLCache defaultCachePath]];
[NSURCache setSharedCache:cache];
Where memoryCapacity == 0. Setting this to some realistic value like 10MB stopped the messages from being issued and appeared to retrieve objects from the cache as I would expect.
其中 memoryCapacity == 0。将其设置为一些实际值,如 10MB 会阻止消息的发出,并且似乎像我期望的那样从缓存中检索对象。
Unfortunately or otherwise depending on your perspective NSURLRequest etc behaviour changed with iOS 5. NSURLRequestCachePolicy is now acted upon, meaning you will need to check which iOS version your app is running on and adjust your caching behaviour accordingly.
不幸的是,根据您的观点,NSURLRequest 等行为随着 iOS 5 发生了变化。 NSURLRequestCachePolicy 现在被执行,这意味着您需要检查您的应用程序正在运行的 iOS 版本并相应地调整您的缓存行为。
回答by iPatel
I have same issue as like you. I don't know but I did fixed it by using following formation in viewDidLoad
method.
我和你有同样的问题。我不知道,但我确实通过在viewDidLoad
方法中使用以下形成来修复它。
-(void) viewDidLoad
{
// First write my code of UI Creation.
// Then I call
[super viewDidLoad]; //add [super viewDidLoad] AFTER implementation, not before.
}
This is working well for me, hope this is also work for you.
这对我来说效果很好,希望这也适合你。