小编lim*_*boy的帖子

为什么NSURLSession不使用我配置的NSURLCache?

iOS7带来NSURLSessionNSURLSessionConfigure,我们可以自定义URLCache,所以我尝试了,但没有运气,似乎我的URLCache根本没用过.

- (void)testURLCache
{
    NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
    config.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
    NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:1024 * 100 diskCapacity:1024 * 100 diskPath:@"test.urlcache"];

    NSLog(@"usage:%lu", (unsigned long)[cache currentDiskUsage]);

    config.URLCache = cache;

    NSURLSession *session = [NSURLSession sessionWithConfiguration:config];
    for (int i = 0; i < 40; i++) {
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js?%d", i]]];
        NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            if (error) {
                NSLog(@"error:%@", error);
            } else {
                NSLog(@"done:%d", i); …
Run Code Online (Sandbox Code Playgroud)

caching objective-c nsurlcache ios7 nsurlsession

5
推荐指数
1
解决办法
4579
查看次数

如何缓存 github 存储库,以便第二个 git 克隆将使用缓存而不是 github 存储库

塞纳里奥:

1)我们在中国,所以访问 github 很慢,有时甚至是不可能的,而且正如你所知,我们不能没有 github。

2)在开发iOS项目时,我们使用Cocoapods,它使用了很多github repos,所以在安装pods时,git clone git@github.com/reactivecocoa/ReactiveCocoa会触发很多类似的命令。

那么我们有什么办法可以改进这个过程呢?对我来说最好的解决方案似乎是对这些 github 存储库进行本地缓存,当触发git clone git@github.com/reactivecocoa/ReactiveCocoa它时实际上是触发git clone http://192.168.1.199/repos/reactivecocoa/ReactiveCocoa,并且服务器可以判断某个 pod 是否存在,如果存在则返回缓存,否则发出 github 请求并缓存结果。

但找不到可行的策略来实现这一目标,有什么建议吗?

git caching github

5
推荐指数
1
解决办法
1566
查看次数

这是一个php bug吗?(关于延伸)

class A extends B {}
class B extends C{}
class C {}
Run Code Online (Sandbox Code Playgroud)

结果

PHP Fatal error: class 'B' not found ...
Run Code Online (Sandbox Code Playgroud)

如果订单是这样的

class A extends B {}
class C {}
class B extends C{}
Run Code Online (Sandbox Code Playgroud)

一切都好.


PS:如果我删除C类{}

class A extends B {}
class B extends C{}
Run Code Online (Sandbox Code Playgroud)

php告诉我没有找到'B'班,为什么?

php版本5.3.4

php

3
推荐指数
1
解决办法
162
查看次数

Flutter Container 的 BoxConstrains 未按预期工作

这是代码

return MaterialApp(
  home: Container(
    constraints: BoxConstraints.tight(Size(100, 100)),
    decoration: BoxDecoration(color: Colors.yellow),
    child: Card(child: Text('Hello World')),
  ),
);
Run Code Online (Sandbox Code Playgroud)

我期望的Card是 100 x 100,但它不是,它只是拉伸到整个屏幕。为什么会这样?

容器没有像我预期的那样工作

flutter flutter-layout

3
推荐指数
1
解决办法
2213
查看次数

获取 php 方法注释

我想获取一个方法的注释,以下面的方法为例:

/**
* Returns the regex to extract all inputs from a file.
* @param string The class name to search for.
* @return string The regex.
*/
public function method($param)
{
  //...
}
Run Code Online (Sandbox Code Playgroud)

结果应该是

Returns the regex to extract all inputs from a file.
@param string The class name to search for.
@return string The regex.
Run Code Online (Sandbox Code Playgroud)

我发现的方法是使用像 file_get_content 这样的函数来获取文件内容 -> 过滤我想要的方法 -> 使用正则表达式获取评论

好像有点复杂,有什么方便的存档方法吗?

php methods comments

2
推荐指数
1
解决办法
1911
查看次数

"{}"表示数组或

我正在阅读"iphone编程 - 大书呆子牧场指南",并且有一个这样的片段:

static NSString *randomNounList[3] =
{ 
    @"Bear", 
    @"Spork",
    @"Mac"
};
Run Code Online (Sandbox Code Playgroud)

所以randomNounList现在是一个数组?但它被宣布为NSString.括号{}在这里意味着什么?

objective-c

2
推荐指数
1
解决办法
108
查看次数