0

coreDatabase にエンティティ「Day」があります。メソッドで、そのエンティティからデータをフェッチし、それを mutuableArray dayObjects に入れます。ここでコードを見ることができます。

  NSManagedObjectContext *context = [RKManagedObjectStore defaultStore].persistentStoreManagedObjectContext;
    NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Day"];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:
                              @"p_date >= %@ and p_date <= %@",dateString,dateString2];
    [fetchRequest setPredicate:predicate];
    NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"p_id" ascending:YES];
    fetchRequest.sortDescriptors = @[descriptor];
    NSArray *matches = [context executeFetchRequest:fetchRequest error:nil];
    NSLog(@"matches = %@",[matches valueForKey:@"p_date"]);
    arrDateObjects = [matches mutableCopy];

私のcellForRowでこれを行います

  Day *objDay = [arrDateObjects objectAtIndex:indexPath.row-1];
  Cell.titlelabel.text = day.p_from;

私のテーブルビューでは、データが正しく表示されています。問題は、同じことを自分のDidSelectRowAtIndexPath. 私は常にNullを取得しlog day.p_fromます。

誰でも私を助けることができますか?

私のnumberOfSectionsを編集

 (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    int sections = 0;
     sections = 1;

    return sections;
}

私のnumberOfRowsInSection

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int rows = 0;
    rows = 8; //showing 7 days + 1 row for a little title
    return rows;
}

私のCellForRowAtIndexPath

static NSString *simpleTableIdentifier = @"OpeningCell";

OpeningCell *cell = (OpeningCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"OpeningCell" owner:self options:nil];
    cell = [nib objectAtIndex:0];
}

if(indexPath.row == 0){
    cell.lblDay.text = NSLocalizedString(@"lblDag", nil);
    cell.lblFrom.text = NSLocalizedString(@"lblVan", nil);
    cell.lblTill.text = NSLocalizedString(@"lblTot", nil);
}else{
    Day *objDay = [arrDateObjects objectAtIndex:indexPath.row-1];
    NSLog(@"Day object in cell from = %@",objDay.p_from);
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"YYYY-MM-dd"];
    NSDate *date = [dateFormat dateFromString:objDay.p_date];
    NSDateFormatter *dateFormat2 = [[NSDateFormatter alloc] init];
    [dateFormat2 setDateFormat:@"dd/MM"];
    NSString *dateString = [dateFormat2 stringFromDate:date];
    NSLog(@"date: %@", dateString);

    cell.lblShort.text = dateString;
    cell.lblDay.text = [arrDays objectAtIndex:indexPath.row-1];
    NSString *txtFrom = [objDay.p_from substringWithRange:NSMakeRange(0, 5)];
    cell.lblFrom.text = txtFrom;
    NSString *txtTill = [objDay.p_till substringWithRange:NSMakeRange(0, 5)];
    cell.lblTill.text = txtTill;
}
return cell;
4

2 に答える 2

0
 NSLog(@"matches = %@",[matches valueForKey:@"p_date"]);
    arrDateObjects=[[NSMutableArray alloc]init];
    [arrDateObjects addobject:[matches objectAtindex:indexpath.row-1]];

それ以外の

  NSLog(@"matches = %@",[matches valueForKey:@"p_date"]);
    arrDateObjects = [matches mutableCopy];
于 2013-04-09T10:08:02.677 に答える