私はコーディングに不慣れで、誰かが私を助けてくれるかどうか疑問に思っていました。初めてWebサービスを利用しています。ただし、アレイへのアクセスに問題があります。何も出せない。
これで、Webサービスから情報を正常に取得し、NSArrayに保存できます。NSLogを実行すると、コンソールにコンテンツが表示されます。配列の数を確認すると5です。
しかし、どのコンテンツにもアクセスできません。エラー状態:CustomTableView [4083:11303]-[__ NSCFDictionary objectAtIndex:]:認識されないセレクターがインスタンス0xff231b0に送信されました
配列内のさまざまな値にアクセスする方法を本当に知りたいだけです。よろしくお願いします!:)
@property (strong, nonatomic) NSArray *searchedYummlyRecipeList;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
self.searchedYummlyRecipeList = [NSJSONSerialization JSONObjectWithData:self.yummlyRecipesData options:nil error:nil];
//test logging
NSLog(@"Recipe List: %@ ", self.searchedYummlyRecipeList);//prints fine
NSLog(@"Count of test array: %lu", (unsigned long)[self.searchedYummlyRecipeList count]);//prints fine
NSArray *testArray = [[self.searchedYummlyRecipeList objectAtIndex:1]objectForKey:@"criteria"];//breakpoint is here
NSLog(@"test Array: %@", testArray);//doesn't get here
NSLog(@"test Array count: %lu", (unsigned long)[testArray count]);//doesn't get here
}
nslog出力の抽出:
Recipe List: {
attribution = {
html = "<a href='http://www.yummly.com/recipes/onion-soup'>onion soup recipes</a> search powered by <img src='http://static.yummly.com/api-logo.png'/>";
logo = "http://static.yummly.com/api-logo.png";
text = "onion soup recipes: search powered by Yummly";
url = "http://www.yummly.com/recipes/onion-soup";
};
criteria = {
allowedIngredients = (
);
excludedIngredients = (
);
facetFields = (
);
maxResults = 6;
requirePictures = 0;
resultsToSkip = 0;
terms = (
onion,
soup
);
};
facetCounts = {
};
matches = (
{
attributes = {
course = (
Soups,
Appetizers
);
cuisine = (
French
);
holiday = (
Thanksgiving
);
};
flavors = {
bitter = "0.1666666666666667";
meaty = "0.1666666666666667";
piquant = 0;
salty = "0.1666666666666667";
sour = "0.1666666666666667";
sweet = "0.1666666666666667";
};
id = "French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364";
ingredients = (
"beef broth",
"minced garlic",
"stick butter",
"yellow onion",
"french bread",
"worcestershire sauce",
"gruyere cheese",
"low sodium chicken broth",
"dry white wine"
);
rating = 0;
recipeName = "French Onion Soup";
smallImageUrls = (
"http://i.yummly.com/French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364-1512.s.jpg",
"http://i.yummly.com/French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364-1199.s.jpg",
"http://i.yummly.com/French-Onion-Soup-The-Pioneer-Woman-Cooks-_-Ree-Drummond-41364-220.s.jpg"
);
sourceDisplayName = "The Pioneer Woman";
totalTimeInSeconds = 0;
},
{
attributes = {
course = (
"Main Dishes"
);
};
flavors = {
bitter = 1;
meaty = "0.1666666666666667";
piquant = 0;
salty = 1;
sour = "0.1666666666666667";
sweet = "0.3333333333333333";
};
id = "Awesome-Slow-Cooker-Pot-Roast-Allrecipes";
ingredients = (
"onion soup mix",
"condensed cream of mushroom soup",
"pot roast",
water
);
rating = "4.69";
recipeName = "Awesome Slow Cooker Pot Roast";
smallImageUrls = (
"http://i2.yummly.com/Awesome-Slow-Cooker-Pot-Roast-Allrecipes-2.s.png",
"http://i.yummly.com/Awesome-Slow-Cooker-Pot-Roast-Allrecipes-58919.s.png"
);
sourceDisplayName = AllRecipes;
totalTimeInSeconds = 29400;
},
{
attributes = {
course = (
Soups
);
};
flavors = {
bitter = "0.1666666666666667";
meaty = "0.1666666666666667";
piquant = "0.6666666666666666";
salty = "0.1666666666666667";
sour = "0.1666666666666667";
sweet = "0.1666666666666667";
};
id = "Chicken-Soup-for-Knaidelach-The-Shiksa-Blog-48854";
ingredients = (
"sea salt",
"bay leave",
onions,
giblets,
"fresh dill",
"curly-leaf parsley",
"whole cloves",
"chopped leaves",
"black peppercorns",
carrot
);
rating = 0;
recipeName = "Chicken Soup for Knaidelach";
smallImageUrls = (
"http://i.yummly.com/Chicken-Soup-for-Knaidelach-The-Shiksa-Blog-48854-10792.s.png",
"http://i.yummly.com/Chicken-Soup-for-Knaidelach-The-Shiksa-Blog-48854-10711.s.png",
"http://i.yummly.com/Chicken-Soup-for-Knaidelach-The-Shiksa-Blog-48854-10617.s.png"
);
sourceDisplayName = "The Shiksa in the Kitchen";
totalTimeInSeconds = 10800;
},
{
attributes = {
course = (
Soups
);
cuisine = (
American
);
};
flavors = "<null>";
id = "Chicken-Soup-The-Pioneer-Woman-200156";
ingredients = (
ribs,
carrots,
chicken,
"bay leaf",
salt,
parsnips,
"black pepper",
onion,
"chicken broth"
);
rating = 0;
recipeName = "Chicken Soup";
smallImageUrls = (
"http://i.yummly.com/Chicken-Soup-The-Pioneer-Woman-200156-39944.s.png"
);
sourceDisplayName = "The Pioneer Woman";
totalTimeInSeconds = 0;
},