I have a very strange problem. I've made an app, everything works ok. But now it suddenly crashes on my NSMutableArray
.
Here is a screenshot of the situation
A few days ago everything worked normal. Can it be that this comes because of the update of XCODE and IOS 7
or is it something else? Can somebody help me? if you need more detailed information. Please ask.
EDIT The array comes from a mutableCopy of my fetchRequest results.
NSArray *matches = [context executeFetchRequest:fetchRequest error:nil];
newsArray = [matches mutableCopy];
EDIT 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;
}
If you are using ARC I would assign the newsArray using the objective c facilities, ie the generated accessor method.
So it would be
self.newsArray = [[NSMutableArray alloc]init];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.