NSString 'testing'(47)がNSMutableArray 'self.checkfriendData'の内部に存在するかどうかを確認しようとしています。私は以下のコードを使用していますが、私のifステートメントを記録した後は実行されないかのように見えます(ステートメントはtrueですが、以下のコンソールデータを参照してください。なぜこれが機能していないのですか?助けが大いにありがとう!Obj-C:オブジェクトがNSMutableArrayに存在するかどうかを確認しますか?
ViewController.m
NSMutableDictionary *viewParams3 = [NSMutableDictionary new];
[viewParams3 setValue:@"accepted_friends" forKey:@"view_name"];
[DIOSView viewGet:viewParams3 success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.checkfriendData = (NSMutableArray *)responseObject;
NSString *testing = @"47";
NSArray *friendorNo = self.checkfriendData;
if ([friendorNo containsObject:testing]) // YES
{
self.addFriend.hidden = YES;
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
ここself.checkfriendData内だものです:
2017-05-18 19:36:07.266529-0700 This is the friend data check (
{
body = "My name is Britt";
friendphoto = "/sites/default/files/stored/x.jpg";
"node_title" = "Britt";
uid = 47;
}
)
:
このためのコードは次のようになりますか?また、 'friendorNo'は' NSDictionary'型であるべきですか? – CRD
@CRD uidはNSDictionary(これは表示されます)です。つまり、NSStringテストをNSDictionary *テストに変更するだけで問題は解決しますか? – Brittany