1

元のファイルは次のように定義されています。

#define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define kLatestKivaLoansURL [NSURL URLWithString: @"http://www.myurl.com/.json"];

データは次の場所にフェッチされます。

- (void)fetchedData:(NSData *)responseData {

...そして、次の各セルに割り当てられます。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

使用されているファイルを変更するには、これを試しました:

- (IBAction)subRedditChange:(id)sender
{
latestKivaLoansURL = [NSURL URLWithString:@"http://reddit.com/r/aww.json"];
[self.tableView reloadData];

}

何も起こらず、.json 構造は各ファイルで同一であるため、fetchedData は両方で機能します。

4

2 に答える 2

1

url実行時に変更する必要がある場合。のインスタンス変数を作成する必要がありますNSUrl

NSURLでインスタンスを定義NSURL *urlします.h。そして、.mファイルオーバーライドviewDidLoadメソッドで設定しますurl

- (void)viewDidLoad
{
// 
self.url = [NSURL urlWithString: @"http://www.myurl.com/.json"];

}

他のURLでヒットしたいとき。

- (IBAction)subRedditChange:(id)sender
{
self.url = [NSURL urlWithString: @"http://www.myurl.com/.json"];
//Call Some method that fetch data from webservice 
[self.tableView reloadData];
}
于 2013-05-10T20:01:50.257 に答える