2012-10-12 6 views
38

Xcode 4.5.1を使用しています。私はこれが私が見ている比較的新しい行動だと思う。All Exceptionsブレークポイントで__cxa_throwを無視しても安全であることをどのように知ることができますか?

私が有効になって「すべての例外」ブレークポイントで自分のプロジェクトを開発し、テストすることを好みます。

私は__cxa_throw例外を取得していますテーブルビュー、中の細胞にサムネイル画像をロードしていますシナリオに実行されています。 「プログラムの実行を続行する」ボタンをクリックすると、Xcodeはやり直しを続けます。私はサムネイルを取得します。アプリケーションは正常に動作するようです。私はこれが無視するのが安全かどうかをどのように判断できるかについていくつかのヒントを探しています。おそらく、スタックトレースを理解する上でのいくつかのポインタですか?または、他の何か?ここで

は、コードの抜粋である:ここで

NSString *imageStr = item.thumbURL; 
    imageStr = [imageStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    NSURL *imageURL; 

    if (![imageStr isEqualToString:@""]) { 
     imageURL = [NSURL URLWithString:imageStr]; 
     NSLog(@"imageURL: %@",imageURL); 
     if (imageURL == nil) { 
      NSLog(@"imageUrl was nil for string: %@",imageStr); 
     } else { 
      UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
      //spinner.frame = CGRectMake(cell.imageView.frame.size.width/2,cell.imageView.frame.origin.y + cell.imageView.frame.size.height/2,cell.imageView.frame.size.width,cell.imageView.frame.size.height); 
      spinner.frame = CGRectMake(10,20,40,40); 
      [spinner startAnimating]; 
      [cell addSubview:spinner]; 

      dispatch_queue_t downloadQueue = dispatch_queue_create("thumbnail downloader", NULL); 
      dispatch_async(downloadQueue, ^{ 
       NSLog(@"Network request for tour_thumb image: %@",imageStr); 
       UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:imageURL]]; 
       dispatch_async(dispatch_get_main_queue(), ^{ 
        [spinner removeFromSuperview]; 
        UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(8, 8, cell.contentView.frame.size.width/2 - 16, cell.contentView.frame.size.height - 16)]; 
        imgView.image = img; 
        [cell.contentView addSubview:imgView]; 
       }); 
      }); 
      dispatch_release(downloadQueue); 
     } 
    } 

は、私は、スタックトレースに表示されるものです。

#0 0x34a9c524 in __cxa_throw() 
#1 0x387014ce in AddChildNode(XMP_Node*, XML_Node const&, char const*, bool)() 
#2 0x38700d22 in RDF_LiteralPropertyElement(XMP_Node*, XML_Node const&, bool)() 
#3 0x3870094e in RDF_PropertyElementList(XMP_Node*, XML_Node const&, bool)() 
#4 0x38700608 in ProcessRDF(XMP_Node*, XML_Node const&, unsigned int)() 
#5 0x3871480a in XMPMeta::ParseFromBuffer(char const*, unsigned int, unsigned int)() 
#6 0x387095c0 in WXMPMeta_ParseFromBuffer_1() 
#7 0x38725578 in TXMPMeta<std::string>::ParseFromBuffer(char const*, unsigned int, unsigned int)() 
#8 0x387254de in TXMPMeta<std::string>::TXMPMeta(char const*, unsigned int)() 
#9 0x38722b70 in CreateMetadataFromXMPDataInternal(char const*, unsigned long, unsigned int)() 
#10 0x38739a50 in readXMPProperties() 
#11 0x386a01fc in readXMPData() 
#12 0x3868cec8 in initImageJPEG() 
#13 0x3868c2ee in _CGImagePluginInitJPEG() 
#14 0x3867e274 in makeImagePlus() 
#15 0x3867ddde in CGImageSourceCreateImageAtIndex() 
#16 0x38e117b6 in _UIImageRefFromData() 
#17 0x38e116c6 in -[UIImage initWithData:]() 
#18 0x0004cb0a in __57-[ViewController tableView:cellForRowAtIndexPath:]_block_invoke_0 at ViewController.m:335 
#19 0x313fc792 in _dispatch_call_block_and_release() 
#20 0x313ffb3a in _dispatch_queue_drain() 
#21 0x313fd67c in _dispatch_queue_invoke() 
#22 0x31400612 in _dispatch_root_queue_drain() 
#23 0x314007d8 in _dispatch_worker_thread2() 
#24 0x394767f0 in _pthread_wqthread() 
#25 0x39476684 in start_wqthread() 
+1

この質問と(すなわち、標準のObjective-Cの例外をトラップ)以下の答えは、同様のXcode 7.2.1に適用され、あまりにもおそらくそれ以降のバージョン。 – bluebinary

答えて

57

これは深い実装内で明らかにされ、C++例外はの一部にすることができます内部でエラーを通知するために例外を使用することに決めた場合は、通常のフローとなります。

自分でC++を書いていない場合は、は無視しても安全です。

だけトラップ標準のObjective-Cの例外:ここ

objc_exception_throw 
+20

ありがとう、トロイの木馬。ブレークポイントを編集して「Exception:All」を「Exception:Objective-C」に変更しました。それは完璧な意味合いがあります。 –

+5

は、念のために誰かがこれに到達しそう:) http://stackoverflow.com/a/14767076/2298217 – iamdavidlam

29

ゴー:

enter image description here

そして、次の操作を行います。

enter image description here

はこれを有効にするには:

012この中

enter image description here

enter image description here

あなたはまだブレークポイントを追加することの利点の多くを得るでしょうが、あなたはおそらくありませんもののためにアプリのクラッシュを持っていません。とにかく責任がある。今あなたがC++で作業しているなら、あなたはそれについてもっと心配するでしょう。

+2

役立つ、感謝を行う方法がわかりません。 –

関連する問題