我試圖在iPad應用程序的XCode 4中加載一個簡單的plist文件。目標是將它加載到分割視圖的表部分。問題在ViewDidLoad中加載plist到NSArray
我的項目結構和plist中如下所示:
#import <UIKit/UIKit.h>
@class DetailViewController;
@interface RootViewController : UITableViewController {
NSArray *sites;
}
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
@end
我的話,在viewDidLoad中,試圖加載:
然後我在RootViewController的界面聲明數組在plist中:
- (void)viewDidLoad
{
[super viewDidLoad];
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
NSBundle *bundle = [NSBundle mainBundle];
//NSLog(bundle);
NSString *path = [bundle pathForResource:@"StoredSites" ofType:@"plist"];
NSLog(path);
sites = [[NSArray alloc] initWithContentsOfFile:path];
NSLog(@"%d", [sites count]);
}
的NSLog的STA tements先回似乎是有效的路徑,但在嘗試用文件的內容加載的NSArray,它的0計數回來:
我在構建階段檢查看是否出現的文件引用,它似乎是確定:
我知道這一定是一個簡單的問題,但由於某種原因,我沒有看到有什麼遺漏!
我欣賞的幫助 -
一些什麼類似的問題在我以前的帖子討論,請[經過鏈接] [1] [1]:http://stackoverflow.com/questions/6693333/plist-in-xcode-creation-problem – DShah
那是我的確切問題,根節點是包裝在字典中 - 感謝您的鏈接!我upvoted所有的答案:) – Evan
總是歡迎....... – DShah