[iOS] Check key exists in NSDictionary in Objective-C

Posted in :

把 json 轉成 dictionary 後,想檢查看看某一個 key 是不是存在。

objectForKey will return nil if a key doesn’t exist.


ex:

if([obj valueForKey:@"SetEntries"] != nil) {
    // The key existed...

}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *