开发者

How to populate Table View with a .plist file?

开发者 https://www.devze.com 2023-02-22 14:36 出处:网络
hey guys, I created a Table View with Navigation Controller, in a Tab Bar Application. This is the code I used to populate my Table View with data:

hey guys, I created a Table View with Navigation Controller, in a Tab Bar Application. This is the code I used to populate my Table View with data:

- (void)viewDidLoad {
[super viewDidLoad];

self.title = NSLocalizedString(@"Glossary", @"Back");

NSMutableArray *array = [[NSArray alloc] initWithObjects:@"Title1",开发者_开发百科 @"Title2", @"Title3", @"Title4", @"Title5", @"Title6", @"Title7", @"Title8", @"Title9", nil];
self.glossaryArray = array;
[array release];

}

So there are my 9 data examples that I created manually using that array string, but I want to make things easier, how can I populate my Table View using a .plist file? I have a big plist file that I want to load into my Table View, but I don't know how to code it in, hope I can get help with this,

thanks


You can create an array from your plist just by creating it with :

+ (id)arrayWithContentsOfFile:(NSString *)aPath

To find the path of your plist file, you can use NSBundle's

- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension
0

精彩评论

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