2011-09-29 53 views
0

我做了tableView与第二个视图与功能从plist加载数据。它可以工作,但我想将plist放在服务器上,这样当我更改plist上的数据时,应用程序会自动刷新。iphone应用程序 - 在服务器上的plist(自动刷新)

代码:

// Get a plist and copy in its contents into an array 
- (id)initWithLibraryName:(NSString *)libraryName { 
    if ((self = [super init])) { 
     libraryPlist = libraryName; 
     libraryContent = [[NSArray alloc] initWithContentsOfFile: 
          [[NSBundle mainBundle] pathForResource:libraryPlist 
                  ofType:@"plist"]]; 
    } 
    return self; 
} 

// [Safely] returns a "DVD" from the plist. Each item in the data source is a 
// dictionary containing data about the chosen DVD. 
- (NSDictionary *)libraryItemAtIndex:(int)index { 
    return (libraryContent != nil && 
      [libraryContent count] > 0 && 
      index < [libraryContent count]) 
       ? [libraryContent objectAtIndex:index] : nil; 
} 

回答

0
NSURL *url = [NSURL URLWithString:@"http://mydomain.com/file.plist"]; 
NSDictionary *DICTIONARY = [[NSDictionary alloc] initWithContentsOfURL:url]; 

其中DICTIONARY将是你的表的数据源

相关问题