因此,我想从我订阅的日历中读取我的事件数组。这些活动都有类似的格式,例如有两个模块,“生命的意义”和“长跑距离”:
对话:生命的意义
谈话:长距离跑步
对话:生命的意义
对话:生命的意义
谈话:长距离跑步
我希望能够使用这样的东西
[[event.title componentsSeparatedByString:@"Talk: "] objectAtIndex:i];因此,在我的表视图中,我可以有一个“生命的意义”单元格和一个“长距离跑步”单元格。然后选择一个模块,你就可以看到该模块的所有“演讲”。还有其他类别,如“研讨会”和“实践”。
目前,我只显示所有事件的代码如下所示(忽略获取所选日历的事件并生成一个标题为arrEvents的数组)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TableIDCell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TableIDCell"];
}
// Get each single event.
EKEvent *event = [self.arrEvents objectAtIndex:indexPath.row];
// Set its title to the cell's text label.
cell.textLabel.text = event.title;
// Get the event start date as a string value.
NSString *startDateString = [self.appDelegate.eventManager getStringFromDate:event.startDate];
// Get the event end date as a string value.
NSString *endDateString = [self.appDelegate.eventManager getStringFromDate:event.endDate];
// Add the start and end date strings to the detail text label.
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ - %@", startDateString, endDateString];
if (indexPath.row%2 == 0) {
UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1];
cell.backgroundColor = altCellColor;
}
return cell;
}感谢您抽出时间来阅读:)
发布于 2015-01-31 20:53:52
最后,我通过修改生成它的类中的arrEvents对它进行了排序。我能够检查它是否包含字符串"Talk:“,然后他们删除那个位,并检查arrEvents是否已经包含标题,然后不添加重复项。
https://stackoverflow.com/questions/28136503
复制相似问题