我有一个非常奇怪的问题。我做了一个应用程序,一切正常。但现在它突然在我的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;
}