2
我正在開發iPhone應用程序。我正嘗試通過Gmail服務器發送包含smtp的URL。我使用CFNetwork框架。有時,郵件沒有問題發送,但很多時候我在該行EXC_BAD_ACCESS得到一個異常EXC_BAD_ACCESS如果exc_bad_access同時向cfnetwork寫入輸出流
(CFWriteStreamCanAcceptBytes(outputStream))
1類:HSK_CFUtilities
CFIndex CFWriteStreamWriteFully(CFWriteStreamRef outputStream, const uint8_t* buffer, CFIndex length)
{
CFIndex bufferOffset = 0;
CFIndex bytesWritten;
while (bufferOffset < length)
{
if (CFWriteStreamCanAcceptBytes(outputStream))
{
bytesWritten = CFWriteStreamWrite(outputStream, &(buffer[bufferOffset]), length - bufferOffset);
if (bytesWritten < 0)
{
// Bail!
return bytesWritten;
}
bufferOffset += bytesWritten;
}
else if (CFWriteStreamGetStatus(outputStream) == kCFStreamStatusError)
{
return -1;
}
else
{
// Pump the runloop
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, true);
}
}
return bufferOffset;
}
2類:SKPSMTPMessage的方法parseBuffer
case kSKPSMTPWaitingSendSuccess:
{
if ([tmpLine hasPrefix:@"250 "])
{
sendState = kSKPSMTPWaitingQuitReply;
NSString *quitString = @"QUIT\r\n";
DEBUGLOG(@"C: %@", quitString);
if (CFWriteStreamWriteFully((CFWriteStreamRef)outputStream, (const uint8_t *)[quitString UTF8String], [quitString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]) < 0)
{
error = [outputStream streamError];
encounteredError = YES;
}
else
{
[self startShortWatchdog];
}
}
我想知道你能不能給我一個提示?我將不勝感激任何幫助 。謝謝你,最好的問候。
你設法解決?我有同樣的問題。 – Kalaichelvan
@Kalaichelvan:是的,我管理,請檢查我的答案這個問題,希望它可以幫助你。 :) – Nico