简体   繁体   English

Xcode 调试:缓存异常?

[英]Xcode debugging: Exception cached?

I have an issue with cached error handling in X-Code.我对 X-Code 中的缓存错误处理有疑问。 I commented a particular line out, but i still get the same error for this line.我注释掉了一个特定的行,但我仍然得到该行的相同错误。

I cleaned the project, i deleted the build folder, i replaced (deleted and imported again) all references.我清理了项目,删除了构建文件夹,替换了(删除并再次导入)所有引用。 But still i get an error in the line where is nothing.但是我仍然在什么都没有的行中出现错误。 Even if i comment out everything, i get the same error.即使我注释掉所有内容,我也会得到同样的错误。

- (void) setTileSource: (id<RMTileSource>)newTileSource
{
    if (tileSource == newTileSource)
        return;

    RMCachedTileSource *newCachedTileSource = [RMCachedTileSource cachedTileSourceWithSource:newTileSource];

    newCachedTileSource = [newCachedTileSource retain];
    [tileSource release];
    tileSource = newCachedTileSource;

---> here is the SIGABRT exception ---> 这里是 SIGABRT 异常

     // NSAssert(([tileSource minZoom] - minZoom) <= 1.0, @"Graphics & memory are 
    [projection release];
    projection = [[tileSource projection] retain];

    [mercatorToTileProjection release];
    mercatorToTileProjection = [[tileSource mercatorToTileProjection] retain];

    [imagesOnScreen setTileSource:tileSource];

        [tileLoader reset];
    [tileLoader reload];
}

Shouldn't you retain the titleSource ?你不应该保留titleSource吗? Try,尝试,

tileSource = [newCachedTileSource copy];

I suspect that means that the exception is not caused by the line you commented out.我怀疑这意味着异常不是由您注释掉的行引起的。

Firstly, why do you do this:首先,你为什么这样做:

newCachedTileSource = [newCachedTileSource retain];

retain returns self. retain返回自我。 You don't need to assign the result to the same object pointer.您不需要将结果分配给相同的 object 指针。 If the library overrides retain to return something different, the library is broken.如果库覆盖保留以返回不同的内容,则库已损坏。

Secondly, I think this might be a bug:其次,我认为这可能是一个错误:

[projection release];
projection = [[tileSource projection] retain];

If projection == [tileSource projection] before the release, it may be possible it is somehow getting over released.如果projection == [tileSource projection]在发布之前,它可能会以某种方式过度发布。 Does the problem go away if you do:如果您这样做,问题 go 是否会消失:

RMProjection* newProjection = [[tileSource projection] retain];
[projection release];
projection = newProjection;

Ideally, you would create a synthesized retain property for projection (actually projection could just get the value from the tileSource) like so:理想情况下,您将为投影创建一个合成的保留属性(实际上投影可以从 tileSource 获取值),如下所示:

-(RMProjection*) projection
{
    return [[self tileSoruce] projection];
}

Same for mercatorToTileProjection. mercatorToTileProjection 也一样。

Change [tileSource release];更改[tileSource release]; to [tileSource autorelease];[tileSource autorelease];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM