【发布时间】:2011-10-25 18:49:05
【问题描述】:
我是 iPhone 开发的新手,并且在从这里获得答案方面取得了巨大成功,因此我希望能直接获得帮助。我正在从 plist 将数据读入 tableview。该应用程序工作正常,但我在编译时收到 2 个警告。我知道为什么会出现错误,但我未能成功解决这些问题。虽然这个应用程序有效,但我真的很想有效地解决警告。当我尝试将 NSDictionary 更改为 NSArray 时,警告消失但表格不再填充。
任何帮助将不胜感激。
Staff 和 Data 在 Delegate .h 文件中定义为 NSArray。警告显示在下面的委托 .m 文件中。
我的代表有以下内容:
- (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
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"Data.plist"];
NSString *SPath = [[NSBundle mainBundle] bundlePath];
NSString *StaffPath = [SPath stringByAppendingPathComponent:@"Staff.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
**self.data = tempDict;**
[tempDict release];
NSDictionary *staffDict = [[NSDictionary alloc]initWithContentsOfFile:StaffPath];
**self.staff = staffDict;**
[staffDict release];
在我的员工 ViewController 中,我有以下内容:
if(CurrentLevel == 0) {
//Initialize our table data source
NSArray *staffDict = [[NSArray alloc] init];
self.tableDataSource = staffDict;
[staffDict release];
Midwest_DigestiveAppDelegate *AppDelegate = (Midwest_DigestiveAppDelegate *)[[UIApplication sharedApplication] delegate];
self.tableDataSource = [AppDelegate.staff valueForKey:@"Rows"];
}
else
self.navigationItem.title = CurrentTitle;
【问题讨论】:
-
你解决了吗? @Corey Brown 我遇到了同样的问题
标签: iphone ios xcode nsarray plist