我在我的項目中設置的視圖上測試相等性時遇到了問題。測試UIViews的相等性,需要澄清
這是一篇很長的文章,請耐心等待。我有3個獨立的視圖設置爲同一個XIB的一部分。
每個視圖經由一個IBOutlet
僱主本身連接到文件所有者(UIViewController中)是一個UIViewController
@interface PuzzleViewController : UIViewController {
裏面FileOwner視圖是宣佈爲:
IBOutlet Puzzle1 *p1;
IBOutlet Puzzle2 *p2;
IBOutlet Puzzle3 *p3;
@property (nonatomic, retain) IBOutlet Puzzle1 *p1;
@property (nonatomic, retain) IBOutlet Puzzle2 *p2;
@property (nonatomic, retain) IBOutlet Puzzle3 *p3;
另外我有
UIView *currentPuzzleView;
@property (nonatomic, retain) UIView *currentPuzzleView;
在.m文件,在初始化時,我宣佈目前看來是P1
[self setCurrentPuzzleView:p1];
後,我想檢查,如果當前視圖是其實p1。該比較失敗。
if ([[self currentPuzzleView] isEqual:p1]) {
此外失敗以及
if ([self currentPuzzleView] == p1) {
這是爲什麼?
非常酷;謝謝 – JAM