我正在一個項目,用ttsend照片與smtp。在開始時,自動引用計數被禁用,項目運行沒有問題。當我啓用自動引用計數時,我得到了許多編譯錯誤。其中最常見的是在該線轉換objective-c指針類型nsoutputstream *到c指針類型cfwritestreamref異常後__bridge
if (CFWriteStreamWriteFully((CFWriteStreamRef)outputStream, (const uint8_t *)[ehlo
UTF8String], [ehlo lengthOfBytesUsingEncoding:NSUTF8StringEncoding]) < 0)
當我寫 如果鑄造目標C指針類型「NSOutputStream *」的至C指針類型CFWriteStreamRef(又名「struct_CFWriteStream *」需要橋接鑄)(CFWriteStreamWriteFully ((__bridge CFWriteStreamRef)的OutputStream,(常量uint8_t *)
[EHLO UTF8字符串],[EHLO lengthOfBytesUsingEncoding:NSUTF8StringEncoding])< 0)
它編譯,但我得到運行時異常時,我按下發送鍵以發送電子郵件與smtp。我想知道你是否可以幫助我解決這個問題。我將不勝感激任何幫助。在此先感謝您,此致敬意
非常感謝您的幫助。但是,我試過了,它沒有奏效。代碼如下: 如果(CFWriteStreamWriteFully((CFWriteStreamRef)的OutputStream, 常量uint8_t *)[EHLO UTF8字符串],[EHLO lengthOfBytesUsingEncoding:NSUTF8StringEncoding])<0){ 錯誤 = [OutputStream的streamError]; encounterError = YES; } else { [self startShortWatchdog]; } –
CFIndex CFWriteStreamWriteFully(CFWriteStreamRef的OutputStream, 常量uint8_t * 緩衝器,CFIndex長度) { CFIndex bufferOffset = 0; CFIndex bytesWritten; 而(bufferOffset <長度) { 如果(CFWriteStreamCanAcceptBytes(OutputStream中)) { bytesWritten = CFWriteStreamWrite(OutputStream中,& (緩衝液[bufferOffset]), - bufferOffset); if(bytesWritten <0) { //保釋! 返回bytesWritten; } –
bufferOffset + = bytesWritten; } else if(CFWriteStreamGetStatus(outputStream) == kCFStreamStatusError) return -1; } else //泵浦runloop CFRunLoopRunInMode(kCFRunLoopDefaultMode,0。0,true); } } return bufferOffset; } [self startShortWatchdog]; } –