0
다음은 로그 파일을 FTP에 업로드하는 코드이며 [mInputStream 열기]를 실행할 때 문제가 발생하는 경우가 있습니다. Xcode는 BAD_ACCESS를 보여줍니다. 큰 크기의 파일을 업로드 할 때 발생할 수 있습니다. 그러나 BADACCESS가 때때로 발생하며 파일 크기가 작을지라도. 그래서 크기가 주된 이유는 아니라고 생각합니다. 누구든지 도울 수 있니? 대단히 감사합니다.NSInputStream open BAD_ACCESS
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
BOOL success;
NSURL *url;
CFWriteStreamRef ftpStream;
mFinish = NO;
mUploadPath = [[NSString alloc] initWithFormat:@"%@/%@",[UtilityHelper logFolderPath], [mPathList objectAtIndex:0]];
//NSLog(@"mUpLoadPath:%d",[mUploadPath retainCount]);
[mPathList removeObjectAtIndex:0];
// check url
url = [UtilityHelper smartURLForString:FTP_URL];
url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", url.absoluteString, [[UIDevice currentDevice] uniqueIdentifier]]];
success = (url != nil);
if (success) {
url = [NSMakeCollectable(CFURLCreateCopyAppendingPathComponent(NULL, (CFURLRef) url, (CFStringRef) [mUploadPath lastPathComponent], false)) autorelease];
success = (url != nil);
}else
return;
mInputStream = [[NSInputStream inputStreamWithFileAtPath:mUploadPath] retain];
[mInputStream open];
// Create CFFTPStream for the URL
ftpStream = CFWriteStreamCreateWithFTPURL(NULL, (CFURLRef) url);
assert(ftpStream != NULL);
mNetworkStream = [(NSOutputStream*)ftpStream retain];
NSLog(@"<<<<<<**>retain count:%d", [mNetworkStream retainCount]);
success = [mNetworkStream setProperty:FTP_USERNAME forKey:(id)kCFStreamPropertyFTPUserName];
assert(success);
success = [mNetworkStream setProperty:FTP_PWD forKey:(id)kCFStreamPropertyFTPPassword];
assert(success);
//[mNetworkStream self
mNetworkStream.delegate = self;
[mNetworkStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[mNetworkStream open];
CFRelease(ftpStream);
[pool release];