2

このトピックに関する多くの記事を読んでいますが、私の問題を解決するための回答が見つかりません...その理由から、助けてください:tableview reloadDataが機能しません... - NSArray invalid summary

私はSplitViewControllerテンプレートを持つiPadアプリを持っています。したがって、RootViewControllerはUITableViewControllerの型です。私のデータは2つの配列に格納され、XMLParser(クラスSyncController)で埋められます。しかし、のtableViewは...データは表示されません

まずAppDelegateでパーサの私の呼び出し:作品

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // Override point for customization after application launch. 
    // Add the split view controller's view to the window and display. 


    self.window.rootViewController = self.splitViewController; 
    [self.window makeKeyAndVisible]; 

    syncController = [[SyncController alloc] init]; 

    [syncController syncData]; 

    return YES; 
} 

。私は私のRootViewControllerに転送したい、SyncControllerは、XMLを解析していると最後に、私は私のデータで埋めSyncControllerの2つのインスタンス変数(NSMutableArrays)を持っている:

rootViewController.visitorNames = [[NSArray alloc] initWithArray:self.visitorNames]; 
rootViewController.visitorCompanies = [[NSArray alloc] initWithArray:self.visitorCompanies]; 
[rootViewController.tableView reloadData]; 

reloadDataが動作しているようです:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
NSLog(@"comp count: %u", [self.visitorCompanies count]); 
return [self.visitorCompanies count]; } 

。コンソールは ...要素の右の数を示ししかし、その後、cellForRowAtIndexPathが

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSLog(@"testghjgjggjgjggjghjghjghjghjghjghjjhgghj"); 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 


// Configure the cell. 
cell.textLabel.text = [self.visitorCompanies objectAtIndex:indexPath.row]; 

return cell; 
} 

THERと呼ばれていませんeはコンソール出力ではありません。 は、だから私は、インスタンス変数

Debug Output

を見てnumberOfRowsInSectionにブレークポイントを設定した彼らはOKのように見えるが、あなたはのtableViewの_dataSourceを見たとき、あなたは無効な要約があることがわかり...

なぜ私のTableViewが機能しないのかと思います。

情報:あなたはSyncControllerを介してデータをロードしないとき、それは正常に動作として、私はSyncControllerを使用し、RootViewControllerののviewDidLoadで固定値でNSArraysを初期化していない場合は、それが正常に動作します

答えて

0

、私は思いますテーブルビューのデータソースは正常に動作しており、出力はNSLog()で生成されます。

SyncControllerに間違いがあります。あなたのコード例:

rootViewController.visitorNames = [[NSArray alloc] 
            initWithArray:self.visitorNames]; 
rootViewController.visitorCompanies = [[NSArray alloc] 
             initWithArray:self.visitorCompanies]; 
[rootViewController.tableView reloadData]; 

このコードはSyncControllerで行われます。また:

// is self instance of SyncController, the app delegate ? 
syncController = [[SyncController alloc] init]; 
// syncController.rootViewController = self.rootViewController ? 
[syncController syncData]; 

データを同期する前にこのプロパティを設定しないでください。

アプリのデリゲートとルートビューコントローラの両方がvisitorNamesvisitorCompaniesという名前のプロパティを持っている場合はそうでなければ、あなたはいくつかのデータで配列を埋めるためには、アプリのデリゲートへの参照をあなたのsyncControllerオブジェクトを送信する必要があります。このことができますinvalid summary problem while debugging in Xcode … 希望:

また、これはSO &答えを問う協議することができます。

+0

不足しているプロパティrootViewControllerが解決策でした。 syncController.rootViewController = selfです。rootViewController < - 働いた!ありがとうございました! – Mceee

関連する問題