1

我有一个非常奇怪的问题。我做了一个应用程序,一切正常。但现在它突然在我的NSMutableArray.

这是情况的截图

在此处输入图像描述

几天前一切正常。这可能是因为更新XCODE and IOS 7还是其他原因?有人可以帮助我吗?如果您需要更详细的信息。请问。

编辑 该数组来自我的 fetchRequest 结果的 mutableCopy。

NSArray *matches = [context executeFetchRequest:fetchRequest error:nil];
newsArray = [matches mutableCopy];

编辑 2

    -(void)fetchNews{
        newsArray = [[NSMutableArray alloc]init];
        RKManagedObjectStore *store = [[TerbremeDataModel sharedDataModel] objectStore];
        NSManagedObjectContext *context = store.mainQueueManagedObjectContext;

        NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"News"];

        NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"new_id" ascending:NO];
        fetchRequest.sortDescriptors = @[descriptor];
        NSArray *matches = [context executeFetchRequest:fetchRequest error:nil];
        newsArray = [matches mutableCopy];
        [tableview reloadData];
    }

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @"NewsCell";

    NewsCell *cell = (NewsCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NewsCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"tablecellbg.png"]];
    cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"tableArrow.png" ]];
    News *news = [newsArray objectAtIndex:indexPath.row];
    NSLog(@"news is %@",news);
    static NSDateFormatter *df;
    static NSDateFormatter *df2;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        df = [[NSDateFormatter alloc] init];
       [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

        df2 = [[NSDateFormatter alloc] init];
        [df2 setDateFormat:@"d MMMM yyyy"];
    });


    cell.lblText.font = [UIFont fontWithName:@"GillSans" size:15.0];
    cell.lblDate.font = [UIFont fontWithName:@"GillSans" size:15.0];

    cell.lblDate.textColor = [UIColor colorWithRed:(154/255.0) green:(202/255.0) blue:(0/255.0) alpha:100];

    cell.lblText.text = news.new_title;
    NSDate *date = [df dateFromString:news.new_datepublished];
   cell.lblDate.text = [df2 stringFromDate:date];

    return cell;
}
4

1 回答 1

0

如果您使用 ARC,我将使用目标 c 工具(即生成的访问器方法)分配 newsArray。

所以它会是

self.newsArray = [[NSMutableArray alloc]init];

于 2013-09-24T13:20:15.597 回答