gpt4 book ai didi

objective-c - @autorelease 指令和异常处理

转载 作者:行者123 更新时间:2023-12-04 03:09:52 24 4
gpt4 key购买 nike

- (void)foo
{
@try {
for (id o in os){
@autoreleasepool {
for (id o2 in moreOs){
// create a lot of autoreleased objects.
}
//exception raised
}
}

}
@catch (NSException *exception) {
// handle the exception
}
}
  1. 如果发生异常,编译器会重写上述代码以排空池还是会泄漏?

  2. 如果编译器确实重写了它,它将如何重写?

最佳答案

不会耗尽水池。来自 Transitioning to ARC Release Notes :

On entry, an autorelease pool is pushed. On normal exit (break, return, goto, fall-through, and so on) the autorelease pool is popped. For compatibility with existing code, if exit is due to an exception, the autorelease pool is not popped.

关于objective-c - @autorelease 指令和异常处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8480624/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com