我已通过以下方式将内存分配给 NSMutable 数组
NSMutableArray *typedBookCollection=[[NSMutableArray alloc] init];
现在我将数组保存到可变字典中。
[self.bookCollectionDictionary setObject:typedBookCollection forKey:bookType];
字典的输出是
book details = {
"Cookery Books" = (
);
Others = (
);
"Social Books" = (
);
"Story Books" = (
);
"Technical Books" = (
);
"Travel Books" = (
);
}
我通过以下代码在指定的书籍数组中添加书籍
for(Book *localBook in books)
{
printf("\n\nBook found in database=%i",[books count]);
printf("\nBook type found =%s",[localBook.type UTF8String]);
NSMutableArray *typedBookArray=[self.bookCollectionDictionary objectForKey:localBook.type];
NSLog(@"\nGoing to add books in typed array=%@",typedBookArray);
[typedBookArray addObject:localBook];
//[[self.bookCollectionDictionary objectForKey:localBook.type]addObject:localBook];
printf("\nOne book added successfully in typedArray=%s",[localBook.title UTF8String]);
NSLog(@"\nBook details=%@",localBook.title);
}
但是每当我尝试通过 NSLog 打印它时它是(空)