1

我正在使用 CTCallCenter 注册呼叫事件。

CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler=^(CTCall* call)
{
    if (call.callState == CTCallStateDisconnected)
    { 
        //we know that the call has ended.
        [self phoneCallEnded];
    }
};

XCode 说它正在泄漏......有道理。

如果我在这里释放callCenter,则不会调用 eventHandler。

我的问题是,我必须在何时何地发布它?我应该让它成为成员并在dealloc()' 中发布它吗?

4

2 回答 2

2

按照您的建议使其成为成员。

于 2011-12-26T11:06:52.643 回答
0

使用 NSAUTORelease 池。之间写你的代码

NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init];


/////Write Your Code of phone call ended

[pool release];
于 2011-12-26T11:10:27.747 回答