如何将 Plist 文件与 UITableView / UICollectionView 一起使用?
Posted
技术标签:
【中文标题】如何将 Plist 文件与 UITableView / UICollectionView 一起使用?【英文标题】:How do I use a Plist file with a UITableView / UICollectionView? 【发布时间】:2014-04-16 19:15:24 【问题描述】:我正在创建一个基本的音乐应用程序 - 乐队的专辑首先显示在 UICollectionView
中,然后当我点击专辑时,我会被推送到详细视图,其中显示有关所选专辑的信息,以及与专辑曲目列表。该应用程序的重点是能够单击曲目列表单元格,然后播放歌曲。
我有这些包含所有专辑完整曲目列表的庞大数组,不酷,太大。
有人告诉我可以使用 Plist 文件。但是,我想知道如何将所有信息放在 一个 plist 文件中,因为我有几张专辑,因此有几个曲目列表。我应该创建一个列出所有专辑的 plist 文件吗?那么接下来我应该在哪里插入曲目列表呢?
你能给我指出一个解决方案吗?
这是我的故事板的屏幕截图:
Click here to view screenshot full screen.
我是初学者,想优化我的代码。我还不能让单元格中的歌曲播放。
CollectionViewController.h:
#import <UIKit/UIKit.h>
@interface CollectionViewController : UICollectionViewController
@property (strong, nonatomic) NSArray *albumImages;
@property (strong,nonatomic) NSArray *albumDescriptions;
@end
CollectionViewController.m:
#import "CollectionViewController.h"
#import "Cell.h"
#import "ImageDetailViewController.h"
@interface CollectionViewController ()
@end
@implementation CollectionViewController
- (void)viewDidLoad
[super viewDidLoad];
self.albumImages = @[@"1998_Yellow.png",@"1998_WoM",@"2000_PoTY",@"2001_SFA",@"2003_MFZB",@"2004_WoMFZB",@"2006_BttW",@"2008_NtnA",@"2008_Phoenix",@"2009_PantyRaid",@"2011_GetNice",@"2013_CyF"];
self. albumDescriptions = @[@"Yellow [1998]",@"Waste of Mind [1998]",@"Playmate of the Year [2000]",@"Stupid Fat Americans - EP [2001]",@"MFZB [2003]",@"Waste of MFZB [2004]",@"Broadcast to the World [2006]",@"Not the New Album - EP [2008]",@"Phoenix [2008]",@"Panty Raid [2009]",@"Get Nice! [2011]",@"Call Your Friends [2013]" ];
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
return self.albumImages.count;
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
UIImage *albumImage = [[UIImage alloc] init];
albumImage = [UIImage imageNamed:[self.albumImages objectAtIndex:indexPath.row]];
cell.imageView.image = albumImage;
return cell;
NSLog(@"Cellule cliquée");
#pragma mark - Prepare for Segue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
UICollectionViewCell *cell = (UICollectionViewCell *)sender;
NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];
NSLog(@"Segue versDetails");
ImageDetailViewController *imageDetailViewController = (ImageDetailViewController *)segue.destinationViewController;
imageDetailViewController.albumImage = [UIImage imageNamed:[self.albumImages objectAtIndex:indexPath.row]];
imageDetailViewController.albumLabelText = [self. albumDescriptions objectAtIndex:indexPath.row];
- (void)viewWillAppear:(BOOL)animated
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
- (void)viewDidDisappear: (BOOL)animated
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@end
ImageDetailViewController.h:
@interface ImageDetailViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *albumImageView;
@property (strong, nonatomic) IBOutlet UILabel *albumDetailLabel;
@property (strong, nonatomic) UIImage *albumImage;
@property (strong, nonatomic) NSString *albumLabelText;
@property (strong,nonatomic) NSArray *tracklist_Y;
@property (strong,nonatomic) NSArray *tracklist_WoM;
@property (strong,nonatomic) NSArray *tracklist_PotY;
@property (strong,nonatomic) NSArray *tracklist_SFA;
@property (strong,nonatomic) NSArray *tracklist_MFZB;
@property (strong,nonatomic) NSArray *tracklist_WoMFZB;
@property (strong,nonatomic) NSArray *tracklist_BttW;
@property (strong,nonatomic) NSArray *tracklist_NtnA;
@property (strong,nonatomic) NSArray *tracklist_Ph;
@property (strong,nonatomic) NSArray *tracklist_PR;
@property (strong,nonatomic) NSArray *tracklist_GN;
@property (strong,nonatomic) NSArray *tracklist_CyF;
@end
imageDetailViewController.m:
#import "ImageDetailViewController.h"
#import "animationY.h"
@interface ImageDetailViewController ()
@end
@implementation ImageDetailViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
// Custom initialization
return self;
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
return 1;
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return 10;
//return [self.tracklist_Y count];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//Liste des chansons (Tracklist)
//http://blog.safaribooksonline.com/2013/02/26/objective-c-how-to-populate-data-in-uitableviewcontroller/
self.tracklist_Y = [[NSArray alloc]initWithObjects:@"1. Check",@"2. All I Need",@"3. Swing",@"4. Walk Away",@"5. Bootylicious Vinyl",@"6. Hate",@"7. Mindtrip",@"8. Chrome",@"9. Jag Off",@"10. Song 10",nil];
self.tracklist_WoM = [[NSArray alloc]initWithObjects:@"1. Check",@"2. Get Back",@"3. The Real Me",@"4. Someday",@"5. Waste of Mind",@"6. Feel This Way",@"7. Walk Away",@"8. Big Shot",@"9. Swing",@"10. Jag Off",@"11. Time",@"12. Move On",@"13. Flay Daze",@"14. Bootylicious Vinyl",nil];
self.tracklist_PotY = [[NSArray alloc]initWithObjects:@"1. I Am",@"2. Playmate of the Year",@"3. Now or Never",@"4. Wasted",@"5. I'm Money",@"6. Go",@"7. What's Goin' On?",@"8. Subtract You",@"9. The Hell that is my Life",@"10. E Generation",@"11. Livin' Libido Loco",@"12. In My Room",nil];
self.tracklist_SFA = [[NSArray alloc]initWithObjects:@"1. Wasted",@"2. Chrome [Demo Version]",@"3. Swing [Demo Version]",@"4. Deck the Halls (I Hate Christmas) W/Intro",@"5. Jag Off [Live]",@"6. Someday [Live]",@"7. Get Back [Live]",nil];
self.tracklist_MFZB = [[NSArray alloc]initWithObjects:@"1. Rescue Me",@"2. Over the Edge",@"3. Strength",@"4. Hello Tomorrow",@"5. The Set-Up",@"6. Blur",@"7. House is Not my Home",@"8. Into You",@"9. Alone",@"10. Expectations",@"11. Falling Apart",@"12. Let it Ride",@"13. Type A",@"14. Runaway",@"15. Dear You (Far Away)",@"16. The Fear",@"17. Surrender [*]",@"18. Good Things [*]",@"19. Dissatisfied [*]",nil];
self.tracklist_WoMFZB = [[NSArray alloc]initWithObjects:@"1. Are You For Real?",@"2. Let Me Go",@"3. One Less Headache]",@"4. Burn the School Down",@"5. Lightning Rod",@"6. Blindside",@"7. Veils and Visions",@"8. One Shot",@"9. Timing is Everything",@"10. Wannabe",nil];
self.tracklist_BttW = [[NSArray alloc]initWithObjects:@"1. Broadcast to the World",@"2. Rated \"U\" for Ugly",@"3. Anthem",@"4. Enemy",@"5. Back to Normal",@"6. Postcards from Hell",@"7. Karma Flavored Whisky",@"8. Here's to You",@"9. Wake me Up",@"10. Lobotomy for Dummies",@"11. The Walking Dead",@"12. Your New Boyfriend Wears Girl Pants",@"13. Riot Girl [*]",@"14. Down in Flames [*]",@"15. Get on the Bus [*]",@"16. Hit it Again [*]",nil];
self.tracklist_NtnA = [[NSArray alloc]initWithObjects:@"1. Mental Health",@"2. Photographs",@"3. Politics",@"4. The Art of Breaking Up",@"5. We're Not a Cover Band, We're a Tribute Band",nil];
self.tracklist_Ph = [[NSArray alloc]initWithObjects:@"1. HMP",@"2. Hell Yeah!",@"3. Just the Tip",@"4. Mental Health",@"5. The Juggernauts",@"6. Death by Disco",@"7. Be Careful What You Wish For",@"8. Morse Code for Suckers",@"9. Ignite",@"10. Mike Dexter is a God, Mike Dexter is a Role Model, Mike Dexter is an A**hole",@"11. The Junkie and the Halo",@"12. Brixton",@"13. Hit the Ground",@"14. Two Wrongs don't make a Right, but Three Rights make a Left",@"15. All for None and None for All",@"16. Sorry, but Your Friends are Hot",@"17. The Art of Breaking Up [*]",@"18. We're Not a Cover Band, We're a Tribute Band [*]",nil];
self.tracklist_PR = [[NSArray alloc]initWithObjects:@"1. Survivor",@"2. Girls Just Want to Have Fun",@"3. Underneath it All",@"4. Trouble",@"5. London Bridge",@"6. Beautiful",@"7. Girlfriend",@"8. The Sweet Escape",@"9. Jenny from the Block",@"10. Rehab",@"11. Spice Up Your Life",@"12. Oops!... I Did it Again",@"13. Get the Party Started",@"14. Mickey",@"15. All I Want for Christmas is You [*]",@"16. Who Let the Dogs Out [*]",nil];
self.tracklist_GN = [[NSArray alloc]initWithObjects:@"1. Blackout",@"2. Nothing to Lose",@"3. She Don't Wanna Rock",@"4. Ricky Bobby",@"5. Get Nice!",@"6. The Joke's on You",@"7. Nudist Priest",@"8. Galileo Was Wrong",@"9. Truck Stops and Tail Lights",@"10. I'm Definitely Not Gonna Miss You",@"11. Too Bored to Bleed",@"12. Kiss your Ass Goodbye",@"13. This is Gonna Hurt You Way More than it's Gonna Hurt Me",@"14. Demon Days",@"15. Light Up the Sky [*]",@"16. A Freak Gasoline Fight Accident [*]",nil];
self.tracklist_CyF = [[NSArray alloc]initWithObjects:@"1. Sirens",@"2. I'm Just Here for the Free Beer",@"3. With Friends Like These, Who Needs Herpes?",@"4. Call Your Friends",@"5. Murder on the Airwaves",@"6. Public Enemy Number One",@"7. Born to Lose",@"8. Stick Em Up Kid!",@"9. Automatic",@"10. Nerd Armor",@"11. Panic in the Streets",@"12. Don't Believe the Hype",@"13. Until the Sun Comes Up",@"14. Last Call",@"15. Sex, Lies & Audiotape [*]",@"16. Battle of the Bullshit [*]",@"17. Ready Steady Go [*]",nil];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TrackCell"];
if(cell == nil)
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TrackCell"];
// Vérification de quel album a été cliqué;
// Il semble qu'il n'y ait pas moyen d'utiliser un Switch avec un NSString, selon *** : http://goo.gl/dpylqF
if ([_albumDetailLabel.text isEqualToString:@"Yellow [1998]"])
animationY * jouerAnimationY = [[animationY alloc]initWithFrame:CGRectMake(85, -20, 600, 600) prefixNom:@"yellowAnim" nbImages:120];
[self.view addSubview: jouerAnimationY ];
cell.textLabel.text = [self.tracklist_Y objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Yellow";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Waste of Mind [1998]"])
cell.textLabel.text = [self.tracklist_WoM objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Waste of Mind";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Playmate of the Year [2000]"])
cell.textLabel.text = [self.tracklist_PotY objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Playmate of the Year";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Stupid Fat Americans - EP [2001]"])
cell.textLabel.text = [self.tracklist_SFA objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Stupid Fat Americans";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"MFZB [2003]"])
cell.textLabel.text = [self.tracklist_MFZB objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"MFZB";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Waste of MFZB [2004]"])
cell.textLabel.text = [self.tracklist_WoMFZB objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Waste of MFZB";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Broadcast to the World [2006]"])
cell.textLabel.text = [self.tracklist_BttW objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Broadcast to the World";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Not the New Album - EP [2008]"])
cell.textLabel.text = [self.tracklist_NtnA objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Not the New Album";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Phoenix [2008]"])
cell.textLabel.text = [self.tracklist_Ph objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Phoenix";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Panty Raid [2009]"])
cell.textLabel.text = [self.tracklist_PR objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Panty Raid";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Get Nice! [2011]"])
cell.textLabel.text = [self.tracklist_GN objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Get Nice!";
return cell;*/
else if ([_albumDetailLabel.text isEqualToString:@"Call Your Friends [2013]"])
cell.textLabel.text = [self.tracklist_CyF objectAtIndex:indexPath.row];
cell.textLabel.textColor=[UIColor whiteColor];
return cell;
/*cell.textLabel.text = @"Call Your Friends";
return cell;*/
- (void)viewDidLoad
[super viewDidLoad];
self.navigationController.navigationBar.hidden = NO;
self.albumImageView.image = self.albumImage;
self.albumDetailLabel.text = self.albumLabelText;
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@end
【问题讨论】:
一个 plist 可以包含一个字典数组或一个数组字典,并在每个元素内进一步嵌套。 【参考方案1】:我以前也使用视图控制器作为我的数据模型。
您的 Plist 应该是这样的结构。
根(数组) 专辑一(NSDictionary) 专辑图片(NSString) 专辑标签(NSString) 专辑曲目列表 (NSString) 专辑二(NSDictionary) 专辑图片(NSString) 专辑标签(NSString) 专辑曲目列表 (NSString) 专辑三(NSDictionary) 专辑图片(NSString) 专辑标签(NSString) 专辑曲目列表 (NSString) 专辑四(NSDictionary) 专辑图片(NSString) 专辑标签(NSString) 专辑曲目列表 (NSString)代码:
CollectionViewController.h:清空它。
CollectionViewController.m:
#import "CollectionViewController.h"
#import "Cell.h"
#import "ImageDetailViewController.h"
@interface CollectionViewController ()
@property (nonatomic, strong) NSArray *albums;
@end
@implementation CollectionViewController
- (void)viewDidLoad
[super viewDidLoad];
//You dont want this.
/*self.albumImages = @[@"1998_Yellow.png",@"1998_WoM",@"2000_PoTY",@"2001_SFA",@"2003_MFZB",@"2004_WoMFZB",@"2006_BttW",@"2008_NtnA",@"2008_Phoenix",@"2009_PantyRaid",@"2011_GetNice",@"2013_CyF"];
self. albumDescriptions = @[@"Yellow [1998]",@"Waste of Mind [1998]",@"Playmate of the Year [2000]",@"Stupid Fat Americans - EP [2001]",@"MFZB [2003]",@"Waste of MFZB [2004]",@"Broadcast to the World [2006]",@"Not the New Album - EP [2008]",@"Phoenix [2008]",@"Panty Raid [2009]",@"Get Nice! [2011]",@"Call Your Friends [2013]" ];*/
//Do this if you are using a plist
//Makes everything thread happy (maximal responsiveness)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //Get path of application
NSString *documentsDirectory = [paths objectAtIndex:0]; //Get documents path
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"data.plist"]; //Get path to dictionary
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath: path]) //Check if file exists
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"]; //Locate file in bundle
[fileManager copyItemAtPath:bundle toPath: path error:&error]; //Copy file over
self.albums = [[NSArray alloc] initWithContentsOfFile: path]; //Initalize dictionary from plist
dispatch_async(dispatch_get_main_queue(), ^
[self.collectionView reloadData]; //Reload your data
);
);
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
return [self.albums count];
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
Cell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MY_CELL" forIndexPath:indexPath];
UIImage *albumImage = [[UIImage alloc] init];
albumImage = [UIImage imageNamed:[[self.albums objectAtIndex:indexPath.row] objectForKey:@"Album Image"]];
cell.imageView.image = albumImage;
return cell;
NSLog(@"Cellule cliquée");
#pragma mark - Prepare for Segue
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
UICollectionViewCell *cell = (UICollectionViewCell *)sender;
NSIndexPath *indexPath = [self.collectionView indexPathForCell:cell];
NSLog(@"Segue versDetails");
ImageDetailViewController *imageDetailViewController = (ImageDetailViewController *)segue.destinationViewController;
imageDetailViewController.album = [self.albums objectAtIndex:indexPath.row];
- (void)viewWillAppear:(BOOL)animated
[self.navigationController setNavigationBarHidden:YES animated:animated];
[super viewWillAppear:animated];
- (void)viewDidDisappear: (BOOL)animated
[self.navigationController setNavigationBarHidden:NO animated:animated];
[super viewDidDisappear:animated];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@end
ImageDetailViewController.h:
@interface ImageDetailViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *albumImageView;
@property (strong, nonatomic) IBOutlet UILabel *albumDetailLabel;
/*@property (strong, nonatomic) UIImage *albumImage;
@property (strong, nonatomic) NSString *albumLabelText;*/
@property (nonatomic, strong) NSDictionary *album;
/*@property (strong,nonatomic) NSArray *tracklist_Y;
@property (strong,nonatomic) NSArray *tracklist_WoM;
@property (strong,nonatomic) NSArray *tracklist_PotY;
@property (strong,nonatomic) NSArray *tracklist_SFA;
@property (strong,nonatomic) NSArray *tracklist_MFZB;
@property (strong,nonatomic) NSArray *tracklist_WoMFZB;
@property (strong,nonatomic) NSArray *tracklist_BttW;
@property (strong,nonatomic) NSArray *tracklist_NtnA;
@property (strong,nonatomic) NSArray *tracklist_Ph;
@property (strong,nonatomic) NSArray *tracklist_PR;
@property (strong,nonatomic) NSArray *tracklist_GN;
@property (strong,nonatomic) NSArray *tracklist_CyF;*/
@end
ImageDetailViewController.m
#import "ImageDetailViewController.h"
@interface ImageDetailViewController ()
@end
@implementation ImageDetailViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
// Custom initialization
return self;
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
return 1;
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [[self.album objectForKey:@"Album Tracklist"] count];
//return [self.tracklist_Y count];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//Liste des chansons (Tracklist)
//http://blog.safaribooksonline.com/2013/02/26/objective-c-how-to-populate-data-in-uitableviewcontroller/
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TrackCell"];
if(cell == nil)
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TrackCell"];
cell.textLabel.text = [[self.album objectForKey:@"Album Tracklist"] objectAtIndex:indexPath.row];
cell.textLabel.textColor = [UIColor whiteColor];
return cell;
- (void)viewDidLoad
[super viewDidLoad];
self.navigationController.navigationBar.hidden = NO;
self.albumDetailLabel = [self.album objectForKey:@"Album Label"];
- (void)didReceiveMemoryWarning
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
@end
所以基本上在这里,你有一个专辑数组,当你为关键事物做对象时,你正在提取图像、标签和曲目列表。我尽力使您的代码 plist 友好,但它可能并不完美......
【讨论】:
以上是关于如何将 Plist 文件与 UITableView / UICollectionView 一起使用?的主要内容,如果未能解决你的问题,请参考以下文章
如何将数据从基于 plist 的 UITableView 传递到 UIViewController
将 plist 数据加载到 UITableView 时从不调用惰性初始化程序