3

iOS Developer Center からダウンロードした SampleFTPSample ソース コード (iOS6.0 SDK、Xcode4.5) を実行します。 サンプルFTPSample

イメージとして、ftpServer からリストを取得すると、EXC_BAD_ACCESS エラーが発生することがあります。コードを変更していません。理由がわかりません。どうすれば修正できますか?

どうもありがとうございました。

EXC_BAD_ACCESS 図1 EXC_BAD_ACCESS 図 2 EXC_BAD_ACCESS 図3

4

3 に答える 3

8

これを行うには、(CFReadStreamCreateWithFTPURL を使用して) ストリームを作成した直後に、kCFStreamPropertyFTPAttemptPersistentConnection プロパティを false に設定します。これは次のようになります。

 success = [self.networkStream setProperty:(__bridge id) kCFBooleanFalse
    forKey:(__bridge NSString *) kCFStreamPropertyFTPAttemptPersistentConnection
];
assert(success);
于 2012-10-16T02:28:55.433 に答える
1

うん!! 私はついに解決策を得ました。メインスレッドが終了した後に uialertview show を呼び出したので、今はクラッシュしません。私の場合です。正確な答えはありませんが、このピーターローンを適用することもできます. あなたにも役立つかもしれません。!!

于 2012-10-09T07:04:34.837 に答える
0
- (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];
}

}

于 2012-11-07T11:17:22.477 に答える