2011-02-08 12 views
1

を送ったが、ほとんど私は脳の痛い問題を解決することはできません週です:客観C:認識されていないセレクタがのUIViewControllerサブクラスのサブクラスへ

私は、このプロパティを実装StreamingViewControllerCommonという名前のUIViewControllerのサブクラスを持っている:

@property (nonatomic, assign, readonly) BOOL isMusicStopped; 

そしてもちろん私は、.mファイルに

それを@synthesizeその後、私は、このクラスの2つのサブクラスがありますListen_UIViewControllerLastNews_UIViewControllerself.isMusicStoppedしかしaccessinを呼び出していない変更g直接それに)var isMusicStopped

私はこれを実行しようとすると、この2つのクラスの2のインスタンス(各クラスの1)が含まれているが、私はNSMutableDictionaryを持っている別のクラスでは

:私はこのエラーを取得

if (streamingViews){ 
     for(StreamingViewControllerCommon* aView in streamingViews){ 
      BOOL stopped = aView.isMusicStopped; 
      NSLog(@"%@",stopped); 
      if(stopped){ 
       [aView closeStream]; 
       [streamingViews removeObjectForKey:[aView class]]; 
       [aView release]; 
       aView = nil; 
      } 
     } 
    } 

2011-02-08 15:55:09.760 ProjectName[6182:307] +[LastNews_UIViewController isMusicStopped]: unrecognized selector sent to class 0x2143c 
2011-02-08 15:55:09.768 ProjectName[6182:307] CoreAnimation: ignoring exception: +[LastNews_UIViewController isMusicStopped]: unrecognized selector sent to class 0x2143c 

しかし、奇妙なことStreamingViewControllerCommonにも、これらのメソッドを実装することです:

-(void) destroyStreamer{ 
} 

-(void) closeStream{ 
    [self destroyStreamer]; 
} 

と私が行うとき:私はすべてのエラーを取得していない午前とsubclasseのオーバーライドされたcloseStreamメソッドが右と呼ばれている

NSMutableArray* keys = [[NSMutableArray alloc] initWithArray:[streamingViews allKeys]]; 
    [keys removeObject:[thisView class]]; 
    NSMutableArray *tmp = [[NSMutableArray alloc] initWithArray:[streamingViews objectsForKeys:keys notFoundMarker:@"404"]]; 
    if (tmp){ 
     for (StreamingViewControllerCommon* vc in tmp) 
      [vc closeStream]; 
     [tmp release]; 
    } 

    [streamingViews removeObjectsForKeys:keys]; 

私は間違っていますか?

よろしく、アントニオ

編集:私はコメントで書いたように:この中

if (streamingViews){ 
     for(StreamingViewControllerCommon* aView in streamingViews){ 
      BOOL stopped = aView.isMusicStopped; 
      NSLog(@"%@",stopped); 
      if(stopped){ 
       [aView closeStream]; 
       [streamingViews removeObjectForKey:[aView class]]; 
       [aView release]; 
       aView = nil; 
      } 
     } 
    } 

:各サイクルのためにPザ・:

if (streamingViews){ 
     for (id aViewClass in streamingViews){ 
      StreamingViewControllerCommon* aView = [[streamingViews objectForKey:aViewClass] retain]; 
      //NSLog(@"%@",aView.isMusicStopped); 
      if(aView.isMusicStopped){ 
      [aView closeStream]; 
      [streamingViews removeObjectForKey:aViewClass]; 
      [aView release]; 
      aView = nil; 
     } 
    } 
} 

はトリックをした、これを変更しますNSDictionaryのキーはオブジェクトではなく、オブジェクトのクラスをキーとして使用していたため、私はその奇妙な例外を取得していました

+0

あなたのコメントにThx私は、foreachサイクルから取得したものは、キーではなく、オブジェクトではなく、私はキーとしてクラスを使用していたので、エラーを返したことを理解...サイクルの変更:for(streamingViews内のid aViewClass){ \t \t \t StreamingViewControllerCommon * aView = [[streamingViews objectForKey:aViewClass] retain]; \t \t \t //NSLog(@"%@",aView.isMusicStopped); \t \t \t if(aView。isMusicStopped){ \t \t \t \t [aView closeStream]; \t \t \t \t [streamingViews removeObjectForKey:aViewClass]; \t \t \t \t [aViewリリース]; \t \t \t \t aView = nil; P –

答えて

2

何らかの理由で、streamingViewsにはLastNews_UIViewControllerのインスタンスではなく、クラス自体が含まれているように見えます。それはプラス記号の+[LastNews_UIViewController isMusicStopped]が意味するものです。

+0

をし、なぜ同じことが他の方法の中には発生しません: \t \t \t} \t \t} はトリックをしましたか?なぜ私は[VCクローズストリーム]を行うときに例外がスローされないのですか? –

関連する問題