2016-06-17 5 views
0

セグメント化されたコントロールを使用して、検索のデータをカテゴリに表示しようとしています。しかし、データは受信されても​​、私のテーブルには表示されません。ここでは、2つのView Controllerのコードを示します。子View Controllerは、UITableViewが格納されているView Controllerです。他のビューコントローラテーブルビューからアレイを参照する

PARENT VC

- (void)searchPeople:(NSString*)text { 
    if(![text isEqualToString:@""]){ 
     PFQuery *userWithName = [PFQuery queryWithClassName:@"_User"]; 
     [userWithName whereKey:@"fullName" containsString:text]; 

     PFQuery *userWithHandle = [PFQuery queryWithClassName:@"_User"]; 
     [userWithHandle whereKey:@"username" containsString:text]; 

     PFQuery *userQuery = [PFQuery orQueryWithSubqueries:@[userWithHandle,userWithName]]; 
     [userQuery findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) { 
      NSLog(@"USERS: %@",results); 
      [self.userResults removeAllObjects]; 
      [self.userResults addObjectsFromArray:results]; 
      [[ArrayManager sharedInstance].searchResults addObjectsFromArray:results]; 
      NSLog(@"Count Number: %@", [ArrayManager sharedInstance].searchResults); 
      [[NSNotificationCenter defaultCenter] postNotificationName:@"reload_data" object:self]; 
     }]; 
    } 
} 

CHILD VC

-(void)handle_data { 
    [self.tableView reloadData]; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    NSLog(@"Object Entries: %lu", (unsigned long)[[ArrayManager sharedInstance].searchResults count]); 
    NSMutableArray * array = [[ArrayManager sharedInstance] getGlobalArray]; 

    return [array count]; 
} 

- (void)tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView 
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSDictionary *data = [[ArrayManager sharedInstance]init].searchResults[indexPath.row]; 
    static NSString *MyIdentifier = @"MyIdentifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 

    if (cell == nil) 
    { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
             reuseIdentifier:MyIdentifier]; 
    } 

    cell.textLabel.text = data[@"objectId"]; 
    return cell; 
} 

データがテーブルの上に表示されているデータがない、しかし、サーバーから罰金返されます。 ArrayManagerクラスはシングルトンクラスです。

+0

あなたは子どもの聴衆のどこにいるのですか?子VCは、ViewDidloadにreload_dataオブザーバを登録する必要があります。その方法でテーブル配列を更新する必要があります –

+0

テーブルはどのように再読み込みするよう通知されますか? –

+0

もう1つのものはcontainsStringのマッチングをサポートしていませんbeginWith、endsWith、または完全な値マッチングを許可します –

答えて

関連する問題