I run the SampleFTPSample source code (iOS6.0 SDK, Xcode4.5)which downloaded from iOS Developer Center.
SampleFTPSample
as the Images, when I retrieved a list from ftpServer, sometimes will get EXC_BAD_ACCESS error. I have not modified the code, I don't know why, and How can I fixed it?
Thank you very much.
do this by setting the kCFStreamPropertyFTPAttemptPersistentConnection property to false, immediately after creating the stream (using CFReadStreamCreateWithFTPURL). Here's what that might look like:
success = [self.networkStream setProperty:(__bridge id) kCFBooleanFalse
forKey:(__bridge NSString *) kCFStreamPropertyFTPAttemptPersistentConnection
];
assert(success);
yeahh!! I finally got the solution. I invoked uialertview show after main thread gets finish.So that it wont crash now. It is in mine case. So don't have an exact answer but you can also apply this
peterlawn. May be it will be usefull to you to as well. !!
- (void)_startReceive:(NSString*) urlPath
{
BOOL success;
NSURL * url;
CFReadStreamRef ftpStream;
assert(self.networkStream == nil); // don't tap receive twice in a row!
// First get and check the URL.
if(urlPath != nil)
{
...url = FTP_URL here...
}
success = (url != nil);
// If the URL is bogus, let the user know. Otherwise kick off the connection.
if ( ! success)
{
[self _updateStatus:@"Invalid URL"];
}
else
{
// Create the mutable data into which we will receive the listing.
self.listData = [NSMutableData data];
assert(self.listData != nil);
// Open a CFFTPStream for the URL.
ftpStream = CFReadStreamCreateWithFTPURL(NULL, (__bridge CFURLRef) url);
assert(ftpStream != NULL);
self.networkStream = (__bridge NSInputStream *) ftpStream;
success = [self.networkStream setProperty:(__bridge id) kCFBooleanFalse
forKey:(__bridge NSString *) kCFStreamPropertyFTPAttemptPersistentConnection
];
assert(success);
self.networkStream.delegate = self;
[self.networkStream scheduleInRunLoop:[NSRunLoop currentRunLoop]forMode:NSDefaultRunLoopMode];
[self.networkStream open];
// Have to release ftpStream to balance out the create. self.networkStream
// has retained this for our persistent use.
CFRelease(ftpStream);
// Tell the UI we're receiving.
[self _receiveDidStart];
}
}