小编dea*_*rne的帖子

NSPredicate与NSCompoundPredicate?

使用具有类似"Condition1 AND condition2"的值的单个NSPredicate与使用具有两个子预测的NSCompoundPredicate相比有哪些优缺点?

即使我动态构造它,第一个选项似乎更紧凑的代码.

iphone xcode nspredicate ios

4
推荐指数
1
解决办法
1190
查看次数

iOS URLCache缓存时不应该(恕我直言)

有谁知道为什么这个请求被缓存?

  • 我正在使用未经修改的.default URLSessionConfiguration.

  • 响应标头是:

(来自Charles,通过调试数据任务完成块中的响应确认)

{
    "Accept-Ranges" = bytes;
    "Content-Length" = 1480;
    "Content-Type" = "application/json";
    Date = "Mon, 22 May 2017 19:14:13 GMT";
    Etag = "\"42bebc5fb88323b8cd145ed85ea7a018\"";
    "Last-Modified" = "Mon, 22 May 2017 14:54:38 GMT";
    Server = AmazonS3;
    "x-amz-id-2" = "abcdefghijklmn";
    "x-amz-request-id" = 1A2B3C4D5E;
}
Run Code Online (Sandbox Code Playgroud)
  • 我正在验证使用Charles代理缓存请求 - 第一个请求出现,但后续请求没有.

  • 使用.ephemeral会话配置,或者为内存和磁盘大小设置自定义url缓存为0显示Charles中的所有请求,因此我知道Charles是一个有效的测试.

我一直认为没有缓存标头不会缓存响应:|

任何人的想法?


编辑:这是我正在提出的要求

po task.originalRequest
? Optional<URLRequest>
  ? some : http://s3-eu-west-1.amazonaws.com/path/path/configuration.json
    ? url : Optional<URL>
      ? some : http://s3-eu-west-1.amazonaws.com/path/path/configuration.json
    - cachePolicy : 0
    - timeoutInterval : 60.0
    - …
Run Code Online (Sandbox Code Playgroud)

caching nsurlcache ios nsurlsession

4
推荐指数
1
解决办法
432
查看次数

UINavigationBar左边距

在iPhone 6+上,当你添加自定义左栏按钮项时,看起来UINavigationBars的左边距为20pt.在其他设备上它是16pt.

这很好,在更宽的屏幕设备上可能有助于让拇指触及该按钮:)

我正在尝试将我的UI调整到下面(这是菜单项的表格视图)并且它证明是棘手的.

有没有办法以编程方式获得该边距,因此我可以在我的UI中的其他地方使用该值.

这样的事情是理想的:

CGFloat padding = self.navigationBar.leftMargin;
Run Code Online (Sandbox Code Playgroud)

但显然不存在:(

有什么建议?

iphone uinavigationbar ios

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

在交换机中未处理枚举值'UIGestureRecognizerStatePossible','UIGestureRecognizerStateCancelled'和'UIGestureRecognizerStateFailed'

当我使用手势功能进行上下翻转时,这有助于修复此错误

- (void)doFlipForward:(UIGestureRecognizer *)aGestureRecognizer forOrientation:(UIInterfaceOrientation)anOrientation{
    if(isAnimating)
    return;

switch([aGestureRecognizer state])//There is occurred in this line
{
    case UIGestureRecognizerStateBegan:
        [CATransaction begin];
        [CATransaction setDisableActions:YES];
        [flipPage setHidden:NO];
        [flipShadow setHidden:NO];
        [CATransaction commit];         
        break;

    case UIGestureRecognizerStateChanged:
    {
        CGFloat multiplier = 0.0f;
        if(UIInterfaceOrientationIsPortrait(anOrientation))
        {
            multiplier = portraitMultiplierTable[(NSInteger)[aGestureRecognizer locationInView:self].x];
            [thisPage setPortraitCurlAnimationPosition:multiplier];
            [flipPage setPortraitCurlAnimationPosition:multiplier];
            [flipShadow setPortraitCurlAnimationPosition:multiplier];
        }
        else
        {
            multiplier = landscapeMultiplierTable[(NSInteger)[aGestureRecognizer locationInView:self].x];
            [thisPage setLandscapeCurlAnimationPosition:multiplier];
            [flipPage setLandscapeCurlAnimationPosition:multiplier];
            [flipShadow setLandscapeCurlAnimationPosition:multiplier];
        }
    }
        break;

    case UIGestureRecognizerStateEnded:
    {
        CGFloat transX = [(UIPanGestureRecognizer *)aGestureRecognizer translationInView:self].x;

        CGFloat width = [self bounds].size.height * PAGE_RATIO;
        if(width …
Run Code Online (Sandbox Code Playgroud)

objective-c ios5 xcode4.2

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

代码在R中显示为注释?

我知道:

# this is a comment
code <- ("this is code")
Run Code Online (Sandbox Code Playgroud)

任何人都可以告诉我它是如何可能的,并且一些R代码以绿色(如注释)出现,即使我没有在代码前面说过#?代码可以毫无困难地运行,这是奇怪的部分吗?

我的一个学生有这个"问题",我无法弄清楚为什么代码显示为绿色?

在此先感谢您的回答:)

亲切的问候玛丽亚

comments r

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

从PList读取字典时的错误顺序

我有一个plist,我试图按顺序访问它的动画(在PList中定义),但是当我将它存储在NSDictionary中然后尝试逐个播放动画时它不是按顺序播放它们.例如,

int index = 0;
[self playAnimation:[animTypes objectAtIndex:index++]];
[self playAnimation:[animTypes objectAtIndex:index++]];
Run Code Online (Sandbox Code Playgroud)

这是我的Plist的代码:

<plist version="1.0">
<dict>
<key>Boy</key>
    <dict>
    <key>Enter</key>
    <dict>
        <key>disabled</key>
        <false/>
        <key>halfCycle</key>
        <true/>
        <key>fps</key>
        <integer>1</integer>
        <key>defaultFrame</key>
        <integer>0</integer>
        <key>useZwoptex</key>
        <true/>
        <key>frames</key>
        <array>
            <string>boy-000.png</string>
        </array>
    </dict>
    <key>Jump</key>
    <dict>
        <key>disabled</key>
        <false/>
        <key>halfCycle</key>
        <true/>
        <key>fps</key>
        <integer>13</integer>
        <key>defaultFrame</key>
        <integer>0</integer>
        <key>useZwoptex</key>
        <true/>
        <key>frames</key>
        <array>
            <string>boyjump-000.png</string>
            <string>boyjump-001.png</string>
            <string>boyjump-002.png</string>
        </array>
    </dict>
    <key>Turnaround</key>
    <dict>
        <key>disabled</key>
        <false/>
        <key>halfCycle</key>
        <true/>
        <key>fps</key>
        <integer>21</integer>
        <key>defaultFrame</key>
        <integer>0</integer>
        <key>useZwoptex</key>
        <true/>
        <key>frames</key>
        <array>
            <string>boyturnaround-000.png</string>
            <string>boyturnaround-001.png</string>
            <string>boyturnaround-002.png</string>
        </array>
    </dict>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

Plz指导我如何按顺序加载动画?

iphone nsdictionary plist cocos2d-iphone

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

使用NSNotificationQueue时合并

我编写了以下代码以使用NSNotificationQueue执行合并.我想发布一个通知,即使事件多次发生.

- (void) test000AsyncTesting
{
    [NSRunLoop currentRunLoop];
    [[NSNotificationCenter defaultCenter] addObserver:self             selector:@selector(async000:) name:@"async000" object:self];
    [[NSNotificationQueue defaultQueue] enqueueNotification:[NSNotification notificationWithName:@"async000" object:self]
    postingStyle:NSPostWhenIdle coalesceMask:NSNotificationCoalescingOnName forModes:nil];

    while (i<2)
    {
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
        NSLog(@"Polling...");
        i++;
    }
}

- (void) async000:(NSNotification*)notification;
{
    NSLog(@"NSNotificationQueue");
}
Run Code Online (Sandbox Code Playgroud)

每次调用方法'test000AsyncTesting'时,具有相同名称的通知都会添加到队列中.根据合并的概念,如果队列具有任意数量的通知但具有相同的名称,那么它将仅发布一次.但是当我运行我的代码时,'async000:'被多次调用,这与添加到NSNotificationQueue的通知数完全相同.我认为合并不起作用.
对我来说,在这两种情况下,代码的执行都是相同的:

情况1:[[NSNotificationQueue defaultQueue] enqueueNotification:[NSNotification notificationWithName:@"async000"object:self] postingStyle:NSPostWhenIdle coalesceMask:NSNotificationCoalescingOnName forModes:nil];

情况2:[[NSNotificationQueue defaultQueue] enqueueNotification:[NSNotification notificationWithName:@"async000"object:self] postingStyle:NSPostWhenIdle];

请告诉我的代码中的错误.

iphone objective-c coalescing

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

在目标c中无法理解二传手和吸气剂

我正在通过一些在线教程学习目标c,我有一个问题.在这个视频:http://www.youtube.com/watch?v = Nb9-1rRjO_8&feature = player_detailpage#t = 367s你可以看到我在这里写的代码:

@synthesize width, height; //setters and getters

-(void) setWH:(int) w:(int) h{
    width = w;
    height = h
}
Run Code Online (Sandbox Code Playgroud)

我不明白为什么他写了一个setHW方法,如果他已经使用@synthesize获得了宽度和高度的setter和getter.我错过了什么?

谢谢

getter setter objective-c

0
推荐指数
1
解决办法
133
查看次数

检查数组中对象之间冲突的好方法是什么?

我一直在另一个for循环中进行for循环,以便同时从数组中获取2个对象,但必须有更好的方法.我只想检查它们是否发生碰撞然后从视图和数组中删除它们.

arrays objective-c game-physics physics-engine ios

-1
推荐指数
1
解决办法
242
查看次数