2013-07-16 38 views
-2

這是我的問題。我用UISearchBar在UITableView的MutableArray中顯示文件。從文件/ Plist中讀取可變數組

所以我做了一個數組:

allTableData = [[NSMutableArray alloc] initWithObjects: 
       [[CRFParts alloc] initWithName:@"ABC" andDescription:@"DEF"], 
       [[CRFParts alloc] initWithName:@"GHI" andDescription:@"JKL"], 
       nil]; 

我周圍2000行的這一點。我使用excel文件構建了簡單的字符串,但是.m中的代碼比.m大。是否有可能從文件(plist/txt)中讀取這些內容?

感謝您的幫助!

+2

是的,你可以。有很多例子閱讀plist文件... – Larme

回答

0

試試看This Question。它有很多關於如何閱讀plist和字典與數組的好代碼。

下一次,在你問之前進行搜索。

0

您可以easely使用:
NSArray *array = [[NSArray alloc] initWithContentsOfURL:url];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfURL:url];

退房Apple Documentation的話題。
請注意您正在加載的結構,因爲plist可以在其​​根目錄下表示數組或字典。 Other thread關於它