Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
これが私のコードです..
NSLog(@"%@", [textField テキスト]); NsLog(@"%@", entity.attribute);
ログに値が表示されます
123 と 123 が正しい値です。
しかし、このコードは機能しません
If([textField text] == entity.attribute) NSLog(@"正解!");
ログ「正解!」表示されません..
どうしたの??助けてください
値ではなく NSString* ポインターを比較しています...それらは異なるオブジェクトです。
両方が非 nil の場合 (確認する必要があるかもしれません)、次のように動作します。
If([[textField text] compare:entity.attribute]==NSOrderedSame) NSLog(@"Correct!");