>如何把靜態數據轉換為屬性列表

>如何從屬性列表讀取數據

### 為什么要分離數據

 1 2 3 4 5 6 7 8 // Initialize table data     tableData   =   [ NSArray  arrayWithObjects : @ "Egg Benedict",   @ "Mushroom Risotto",   @ "Full Breakfast",   @ "Hamburger",   @ "Ham and Egg Sandwich",   @ "Creme Brelee",   @ "White Chocolate Donut",   @ "Starbucks Coffee",   @ "Vegetable Curry",   @ "Instant Noodle with Egg",   @ "Noodle with BBQ Pork",   @ "Japanese Noodle with Pork",   @ "Green Tea",   @ "Thai Shrimp Cake",   @ "Angry Birds Cake",   @ "Ham and Cheese Panini",   nil ];           // Initialize thumbnails     thumbnails   =   [ NSArray  arrayWithObjects : @ "egg_benedict.jpg",   @ "mushroom_risotto.jpg",   @ "full_breakfast.jpg",   @ "hamburger.jpg",   @ "ham_and_egg_sandwich.jpg",   @ "creme_brelee.jpg",   @ "white_chocolate_donut.jpg",   @ "starbucks_coffee.jpg",   @ "vegetable_curry.jpg",   @ "instant_noodle_with_egg.jpg",   @ "noodle_with_bbq_pork.jpg",   @ "japanese_noodle_with_pork.jpg",   @ "green_tea.jpg",   @ "thai_shrimp_cake.jpg",   @ "angry_birds_cake.jpg",   @ "ham_and_cheese_panini.jpg",   nil ];           // Initialize Preparation Time     prepTime   =   [ NSArray  arrayWithObjects : @ "30 min",   @ "30 min",   @ "20 min",   @ "30 min",   @ "10 min",   @ "1 hour",   @ "45 min",   @ "5 min",   @ "30 min",   @ "8 min",   @ "20 min",   @ "20 min",   @ "5 min",   @ "1.5 hour",   @ "4 hours",   @ "10 min",   nil ];

### 將表數據轉換到屬性列表中

“recipes.plist”文件的源代碼，會出現這樣的：

### 在Object C中導入屬性列表

 1 2 3 4 5 6 7 8 // Initialize table data     tableData   =   [ NSArray  arrayWithObjects : @ "Egg Benedict",   @ "Mushroom Risotto",   @ "Full Breakfast",   @ "Hamburger",   @ "Ham and Egg Sandwich",   @ "Creme Brelee",   @ "White Chocolate Donut",   @ "Starbucks Coffee",   @ "Vegetable Curry",   @ "Instant Noodle with Egg",   @ "Noodle with BBQ Pork",   @ "Japanese Noodle with Pork",   @ "Green Tea",   @ "Thai Shrimp Cake",   @ "Angry Birds Cake",   @ "Ham and Cheese Panini",   nil ];           // Initialize thumbnails     thumbnails   =   [ NSArray  arrayWithObjects : @ "egg_benedict.jpg",   @ "mushroom_risotto.jpg",   @ "full_breakfast.jpg",   @ "hamburger.jpg",   @ "ham_and_egg_sandwich.jpg",   @ "creme_brelee.jpg",   @ "white_chocolate_donut.jpg",   @ "starbucks_coffee.jpg",   @ "vegetable_curry.jpg",   @ "instant_noodle_with_egg.jpg",   @ "noodle_with_bbq_pork.jpg",   @ "japanese_noodle_with_pork.jpg",   @ "green_tea.jpg",   @ "thai_shrimp_cake.jpg",   @ "angry_birds_cake.jpg",   @ "ham_and_cheese_panini.jpg",   nil ];           // Initialize Preparation Time     prepTime   =   [ NSArray  arrayWithObjects : @ "30 min",   @ "30 min",   @ "20 min",   @ "30 min",   @ "10 min",   @ "1 hour",   @ "45 min",   @ "5 min",   @ "30 min",   @ "8 min",   @ "20 min",   @ "20 min",   @ "5 min",   @ "1.5 hour",   @ "4 hours",   @ "10 min",   nil ];

 1 2 3 4 5 6 7 8 // Find out the path of recipes.plist      NSString   *path   =   [ [ NSBundle  mainBundle ]  pathForResource : @ "recipes"  ofType : @ "plist" ];          // Load the file content and read the data into arrays      NSDictionary   *dict   =   [ [ NSDictionary  alloc ]  initWithContentsOfFile :path ];     tableData   =   [dict objectForKey : @ "RecipeName" ];     thumbnails   =   [dict objectForKey : @ "Thumbnail" ];     prepTime   =   [dict objectForKey : @ "PrepTime" ];