私はこの使用してNSDisctionaryでキーの値を設定しています:私はcurrentColorの値にEXC悪いアクセスアプリのクラッシュを(ログインしようとEXC悪いアクセスエラー
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesEnded currentcolor: %@", currentColor);
if (currentTool == @"paint") {
NSLog(@"End Paint");
CGPoint point = [[touches anyObject] locationInView:self.view];
MaskPath * myNewPath = [mapView.drawthis containsPoint:point];
[myNewPath.attributes setValue:currentColor forKey:@"fill"];
[mapView setNeedsDisplay];
} else {
NSLog(@"End Pattern");
currentColor = @"1.png";
CGPoint point = [[touches anyObject] locationInView:self.view];
MaskPath * myNewPath = [mapView.drawthis containsPoint:point];
[myNewPath.attributes setValue:currentColor forKey:@"fill"];
[mapView setNeedsDisplay];
}
}
3行目) ログアウトしてハードコードされた値を使用すると、すべて正常に動作します。また、ifステートメントの最初の部分でうまく動作します。私はcurrentColorを割り当てる関数をチェックし、正しい値を渡しています。その時点でcurrentColorの値をハードコードするとうまく動作します。私は、アナライザーを実行していると私はメモリリークや問題はありません。この問題を他にどのように追跡できますか?
あなたが宣言され、色を割り当てコードを表示することができますか? –
'NSLog'でクラッシュした場合は、' NSDictionary'とはまったく関係ありません。どこにcurrentColorを設定しますか?私はあなたがそれを正しく保持していないだろうと確信しています:) – deanWombourne
これは、 'currentColor'が割り当て解除されたためです。 'currentColor'を宣言したコードと' touchesEnded:withEvent: 'メソッドの外でそれをどこに設定するのかを指定します。 – Jeremy