代码之家  ›  专栏  ›  技术社区  ›  Tim

NSAutoreleasePool跨方法执行?

  •  1
  • Tim  · 技术社区  · 17 年前

    示例代码:

    - (void)primaryMethod {
        [self performSelectorInBackground:@selector(threadedMethod) withObject:nil];
    }
    
    - (void)threadedMethod {
        NSAutoreleasePool *aPool = [[NSAutoreleasePool alloc] init];
    
        // Some code here
    
        [self anotherMethod];
    
        // Maybe more code here
    
        [aPool drain];
    }
    
    - (void)anotherMethod {
        // More code here
    }

    threadedMethod anotherMethod .

    3 回复  |  直到 17 年前
        1
  •  7
  •   Peter N Lewis    17 年前

        2
  •  0
  •   SwiftArchitect    15 年前

    [self anotherMethod] (void)threadedMethod .

    • Q: NSAutoreleasePool跨方法执行?
    • A: 这取决于:

    NSAutoreleasePool -(void)threadedMethod { } .

    前面提到的文章( http://thegothicparty.com/dev/macos/nsautoreleasepool/

    推荐文章