开发者

Display NSArray values that are stored in an NSDictionary

I'm trying to store an NSArray object with a simple key (1,2,3 etc.) inside an NSDictionary. I'm pretty sure thats worked, but I'm not sure how to display the array data thats stored in there, I've got the following working (displaying a single array of data)

The test app i'm working on is a simple dictionary. Definition is the class i've got for words and their definitions, and words is an array which has two values - word and definition

Definition *words = (Definition *)[appDelegate.words objectAtIndex:indexPath.row];

It then shows the data in a table view:

[cell.textLabel setText:words.name];
[cell.detailTextLabel setText: words.descr开发者_C百科iption];


Not quite sure what you're asking here. You create a Definition instance, so what properties does it have? If you have NSStrings name and description in it, then that code should work fine, but I think you're trying to do something different.

You access information in a NSDictionary by calling objectForKey: or valueForKey:.

You can also store information in the object. If you created your Definition to hold two strings--name and description, you could bypass the NSDictionary all together.

Could you post your Description.h so we can see what's going on?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜