これに関する多くの情報を見つけることができず、この問題がどこから来ているのかを絞り込もうとする運がまったくないので、ここの誰かがもう少し情報と可能性を教えてくれることを願っていますこのエラーが発生する理由について説明します。
常に新しいデータを受信することでデータセットが常に増加しているため、リアルタイムでデータセットをプロットしています。新しいデータを受信すると、それを x として受信し、値自体を y として受信します。これがポイントを生成する方法です。
完全なエラー: 例外がキャッチされていないため、アプリを終了しています'CPTException', reason: 'Number of x and y values do not match'
クラッシュの前に自分のデータ セットを調べました。ポイントの作成に失敗したり、問題が発生したりしていないことを確認しました。この時点で、おそらく numberOfRecordsForPlot 関数で、私のバージョンの散布図と関係があると思います。ただし、その関数のどこでもクラッシュするようには見えません。クラッシュは通常 10 秒以上経過するまで発生しませんが、やはり一貫性がなく、クラッシュしてプロットが完全に機能するようになる前です。
人々がこれに当てることができる光は、非常に高く評価されています。
PS: 人々がコードを見たい場合は、何を教えてください。私ができる限り機能していることを確認した非標準のもの、および散布図に関するものはすべてかなり標準的なものです。
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{
//Translation: The array with key of the top of the first selected parameter
NSInteger curCount = [self.graphParams count];
NSLog(@"Current Count: %d", curCount);
if ([plot.identifier isEqual:@"Sel_1"] && (curCount >= 1) ) {
if ([self.graphParams objectAtIndex: 0] != nil) {
//NSString *myText = ((UITableViewCell *)[self.graphParams objectAtIndex: 0]).textLabel.text;
//NSInteger myNum = [[self.graphData objectForKey: myText] count];
//return [[self.graphData objectForKey: myText] count];
//return [[self.graphData objectForKey: ((UITableViewCell *)[self.graphParams objectAtIndex: 0]).textLabel.text] count];
return [[self.graphData objectForKey: [self.graphParams objectAtIndex: 0]] count];
}
else
return 0;
}
else if ([plot.identifier isEqual:@"Sel_2"] && (curCount >= 2) ) {
if ([self.graphParams objectAtIndex: 1] != nil)
//return [[self.graphData objectForKey: ((UITableViewCell *)[self.graphParams objectAtIndex: 1]).textLabel.text] count];
return [[self.graphData objectForKey: [self.graphParams objectAtIndex: 1]] count];
else
return 0;
}
else if ([plot.identifier isEqual:@"Sel_3"] && (curCount >= 3) ) {
if ([self.graphParams objectAtIndex: 2] != nil)
//return [[self.graphData objectForKey: ((UITableViewCell *)[self.graphParams objectAtIndex: 2]).textLabel.text] count];
return [[self.graphData objectForKey: [self.graphParams objectAtIndex: 2]] count];
else
return 0;
}
return 0;
}
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
//Translation: The array with key of the top of the first selected parameter
NSValue *value = nil;
if ( [plot.identifier isEqual:@"Sel_1"] ) {
value = [[self.graphData objectForKey: [self.graphParams objectAtIndex:0]] objectAtIndex:index];
}
else if ( [plot.identifier isEqual:@"Sel_2"] ) {
value = [[self.graphData objectForKey: [self.graphParams objectAtIndex: 1]] objectAtIndex:index];
}
else if ( [plot.identifier isEqual:@"Sel_3"] ) {
value = [[self.graphData objectForKey: [self.graphParams objectAtIndex: 2]] objectAtIndex:index];
}
if (value != nil)
{
CGPoint point = [value CGPointValue];
if ( fieldEnum == CPTScatterPlotFieldX )
return [NSNumber numberWithFloat:point.x];
else if ( fieldEnum == CPTScatterPlotFieldY )
return [NSNumber numberWithFloat:point.y];
}
return [NSNumber numberWithFloat:0];
}
編集:エラーが発生していると思われる散布図コードを投稿しましたが、これがあなたにとってどれほど役立つかわかりません。いつものように、追加のリクエストについてコメントしてください。意味のあるものは何でも喜んで提供します.