警告'没有明确的所有权'问题档案项目XCode

时间:2016-03-22 21:22:41

标签: ios automatic-ref-counting archive xcode7.2 gcdasyncudpsocket

在Xcode 7.2.1中我存档项目时出现问题,我的应用程序使用WebSocket,我使用CocoaAsyncSocket库,应用程序在模拟器或任何设备上运行但是在存档时,xcode显示此错误警告:

在类GCDAsyncUdpSocket中 在方法中:

 - (void)getDelegate:(id <GCDAsyncUdpSocketDelegate>*)delegatePtr delegateQueue:(dispatch_queue_t *)delegateQueuePtr;

警告错误:

/Users/Dennis/Desktop/WebSocketDennis/CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.m:569:56: Method parameter of type '__autoreleasing id<GCDAsyncUdpSocketDelegate> *' with no explicit ownership

/Users/Dennis/Desktop/WebSocketDennis/CocoaAsyncSocket/Source/GCD/GCDAsyncUdpSocket.m:569:102: Method parameter of type '__autoreleasing dispatch_queue_t *' (aka 'NSObject<OS_dispatch_queue> *__autoreleasing *') with no explicit ownership

我确实尝试了另一个答案,如:

question 1question 2question 3

但如果我需要 ID委托 dispatch_queue_t

为什么只在需要存档项目时出现此问题?

编辑1 在这种情况下,有人知道ARC如何处理间接返回?因为错误警告仅在方法中显示:

.h文件:

- (void)getDelegate:(id <GCDAsyncUdpSocketDelegate>*)delegatePtr delegateQueue:(dispatch_queue_t *)delegateQueuePtr;
- (void)setDelegate:(id <GCDAsyncUdpSocketDelegate>)delegate delegateQueue:(dispatch_queue_t)delegateQueue; 
在.m文件中

- (void)getDelegate:(id  <GCDAsyncUdpSocketDelegate> * )delegatePtr delegateQueue:(dispatch_queue_t *)delegateQueuePtr
{
    if (dispatch_get_specific(IsOnSocketQueueOrTargetQueueKey))
    {
        if (delegatePtr) *delegatePtr = delegate;
        if (delegateQueuePtr) *delegateQueuePtr = delegateQueue;
    }
    else
    {
        __block id dPtr = NULL;
        __block dispatch_queue_t dqPtr = NULL;

        dispatch_sync(socketQueue, ^{
            dPtr = delegate;
            dqPtr = delegateQueue;
        });

        if (delegatePtr) *delegatePtr = dPtr;
        if (delegateQueuePtr) *delegateQueuePtr = dqPtr;
    }
}

- (void)setDelegate:(id <GCDAsyncUdpSocketDelegate>)newDelegate delegateQueue:(dispatch_queue_t)newDelegateQueue synchronously:(BOOL)synchronously
{
    dispatch_block_t block = ^{

        delegate = newDelegate;

        #if !OS_OBJECT_USE_OBJC
        if (delegateQueue) dispatch_release(delegateQueue);
        if (newDelegateQueue) dispatch_retain(newDelegateQueue);
        #endif

        delegateQueue = newDelegateQueue;
    };

    if (dispatch_get_specific(IsOnSocketQueueOrTargetQueueKey)) {
        block();
    }
    else {
        if (synchronously)
            dispatch_sync(socketQueue, block);
        else
            dispatch_async(socketQueue, block);
    }
}

- (void)setDelegate:(id <GCDAsyncUdpSocketDelegate>)newDelegate delegateQueue:(dispatch_queue_t)newDelegateQueue
{
    [self setDelegate:newDelegate delegateQueue:newDelegateQueue synchronously:NO];
}

- (void)synchronouslySetDelegate:(id <GCDAsyncUdpSocketDelegate>)newDelegate delegateQueue:(dispatch_queue_t)newDelegateQueue
{
    [self setDelegate:newDelegate delegateQueue:newDelegateQueue synchronously:YES];
}

我可以在iOS模拟器和任何真实设备上运行该项目,只有当我想要存档项目时才会出现问题,如果我做产品&gt;分析或产品&gt; Build For&gt;运行或测试,运行完美,但当我做产品&gt;存档或产品&gt; Build for&gt;出现错误警告概要

谢谢!

0 个答案:

没有答案