0
我想就下一步做什么以便将Plist中的数据列表传递给数组提供建议。将对象传递给plist的表格单元格
我想将plist数据传递给我的tableview BrowseViewController.m,但我不知道该怎么做。
我试过NSlog,plist正在传递信息,但我不知道wat是我的下一步。
任何人都可以教我吗?非常感谢。
这是我的plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>AudioFileDescriptions</key>
<array>
<string></string>
<string></string>
<string></string>
<string></string>
</array>
<key>CommonName</key>
<string>Cane Toad </string>
<key>ScientificName</key>
<string>Bufo marinus </string>
<key>Species</key>
<string>marinus</string>
</dict>
我的应用程序委托
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
//load frog information from plist
NSBundle *bundle = [NSBundle mainBundle];
NSString *eventsPath = [bundle pathForResource:@"Frog" ofType:@"plist"];
frogObject = [Frog frogObjectWithContentsOfFile:eventsPath];
return YES;
}
Frog.m
+ (id)frogObjectWithContentsOfFile:(NSString *)aPath
{
Frog *frogObject = [[Frog alloc] init];
if (frogObject) {
// load all frogs from plist
NSMutableArray *allFrogsArray = [NSArray arrayWithContentsOfFile:aPath];
//NSDictionary *allFrogsArray = [NSDictionary dictionaryWithContentsOfFile:aPath];
if (allFrogsArray == nil) {
[frogObject release];
}
[frogObject.allFrogs addObjectsFromArray:allFrogsArray];
// iterate through each event and put them into the correct array
NSEnumerator *frogsEnumerator = [allFrogsArray objectEnumerator];
NSDictionary *currentFrog;
while (currentFrog = [frogsEnumerator nextObject]) {
[frogObject addFrog:currentFrog];
}
// NSLog(@"FrogObject %@",allFrogsArray);
}
return frogObject;
}
- (void)addFrog:(NSDictionary *)anFrog;
{
NSLog(@"anFrog Value %@",anFrog);
}
喜可以, 感谢您的答复,你将能够教我如何编写+(NSArray *)函数frogsFromFile:(NSString *)filePath; and - (Frog *)initWithDictionary:(NSDictionary *)frogDictionary; 我该如何使用@property(nonatomic,retain)NSString * species; ???? – Desmond