私のiPhoneアプリケーションはTab based
. タブに、Security Tab
3 つのビュー コントローラーがあるとしFirst, Second, Third
ます。Third
ビューコントローラーからビューコントローラーに文字列値を渡していますSecond
。Third
selectedAlertDesc は、 View Controllerの NSString オブジェクトです。
Third
ビューコントローラーで:
@property (nonatomic,retain) NSString *selectedAlertDesc;
@synthesize selectedAlertDesc = _selectedAlertDesc;
Second
ビューコントローラーで:
Third *controller = [[Third alloc] init];
[controller setSelectedAlertDesc:[[alertArray objectAtIndex:indexPath.row] objectForKey:@"alertDesc"]];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
タブを変更するまでは問題なく動作します。View Controller ページのセキュリティ タブを離れ、Third
別のタブにアクセスした後に戻ってくると、クラッシュします。それは、selectedAlertDescがゾンビになったと述べています。
-[CFString stringByReplacingOccurrencesOfString:withString:]: message sent to deallocated instance 0xeb3d760
この問題を解決するにはどうすればよいですか? 合成されたオブジェクトを初期化すべきではないと思います。私はここで何かを忘れていますか?
編集:
提案されたように、割り当て/保持履歴を確認するためにツールを使用しました。私は以下を手に入れました: - を使用した後selectedAlertDesc
、私はそれを保持しました。やり方は正しいですか??そしてちゃんと動く!!
_selectedAlertDesc = [_selectedAlertDesc stringByReplacingOccurrencesOfString:@"opentag" withString:@"<"];
_selectedAlertDesc = [_selectedAlertDesc stringByReplacingOccurrencesOfString:@"closetag" withString:@">"];
[txtTxtVw setText:_selectedAlertDesc];