English 中文(简体)
GCD阅读旧价值
原标题:Threads from GCD reading old value

我的问题是,使用<条码>发送_async(发送_get_main_queue()、^(ave){......});,在这种方法中,视某些条件而定,将一种方法称作YES。 当用这一方法阅读这种 b时,它有always。 改为: 注

不可思议的是,当我对ool子检查的线上打断点时,所有东西都会被罚款,并按意图!

EDIT: Here is the code where the threads are spawned

dispatch_async(dispatch_get_main_queue(), ^(void) {
    [self drawFaceBoxesForFeatures:features forVideoBox:claporientation:curDeviceOrientation image:img];
});

方法本身

- (void)drawFaceBoxesForFeatures:(NSArray *)features forVideoBox:(CGRect)clap orientation:    (UIDeviceOrientation)orientation image:(UIImage *)image;
{
    if (![self getSendingRequestStatus]) {
        NSLog(@"Sending req");
        // send async request

         dispatch_async(dispatch_get_main_queue(),^ {
             sendingRequest = YES;
         } );
      }
}
最佳回答

它像你一样,正在修改在路障内一个区块外产生的单var。 为了做到这一点并具有正确价值,你将需要使用<代码>_block<>/code>。 关键词如:

@interface MyCoolClass : NSObject {
    @private
    __block int sendingRequest_;
}

正如杰克·劳伦斯在上文的赞扬中所说的那样,“[运行时间]在当时对所有相关物体/变量进行了清点”。 <代码>_block识别符号将显示其时间,即它不应复制ivar to the heap,并将允许你将数值分配到 endingRequest_ within a group,即使该组只是放在主线上。

可以从

问题回答

当原始物品被带入一个路障时,就会被复制。 因此,如果你将原始的当地或地方变量放在一个区块中,然后以相同的方法加以改变,从而造成区块(在区块创建之后)或它所赢得的另一种方法对区块的变数产生任何影响。 就地方变量而言,确保你在制造路障之前作出必要改变。 在个案变数的情况下,您可使用一些C: Self->iVar,尝试查阅案例变数。 或宣布财产为财产,并通过财产存取人查询: Self.iVar





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签