NSDictionary與NSMutableDictionary。
關於NSArray與NSDictionary的分別,
我覺得以下在網路上看到的說明寫得蠻容易懂的。
NSArray is more appropriate when you have a bunch of objects that are all the same type, and you're likely to loop through them in order. For example, a list of books could be put in an NSArray- book[0] is one book, book[1] is another book.
NSDictionary is more appropriate when you have objects (sometimes of different types) that you want to access by keys; often out of order. For example, an individual book could be represented as a Dictionary, where the key "sold" refers to a NSNumber for the number sold, and the key "Title" points to an NSString for the title of the book.
基本上NSArray主要一個主打單純儲存物件,
NSDictionay主打儲存Key-value形式的物件。
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。