Saturday, 7 September 2013

data not being written to NSMutableArray

data not being written to NSMutableArray

I have an iOS app that pulls data from a server and persists it using
CoreData. I have a UITableView that I am trying to populate with only
select portions from a given core data attribute.
Before the table is populated I cycle through the data and pass what I
want into a NSMutableArray. The problem is when I find an item I want it
is not being added to the array.
I declare the array in my .h file like so...
@property (strong, nonatomic) NSMutableArray *theNewSource;
And Synthesize it in the .m file
@synthesize theNewSource = _theNewSource;
Here is the method...
-(NSMutableArray *)setDataSourceArray
{
for(int i = 0; i < rcount ; i++)
{
NSIndexPath *countingInteger = [NSIndexPath indexPathForItem:i
inSection:0];
NSManagedObject *object = [self.fetchedResultsController
objectAtIndexPath:countingInteger];
NSString *action = [object valueForKey:@"theActionName"];
if (![action isEqual:@"Login"])
{
[_theNewSource addObject:action];
}
}
NSLog(@"the array is now %@",_theNewSource);
return _theNewSource;
}
I've set a breakpoint in the line [_theNewSource addObject:action]. I can
see in the console that the variable action does have a value but it is
never added to _theNewSource array... I'm sure this is Objective C 101 but
I can't get it figured out. Please Help!

No comments:

Post a Comment