Reputation: 10245
I am trying to pass an NSArray to a NSMutableArray but am having a few issues doing so and was hoping someone could help.
- (void)CachedData:(NSArray *)gArray indexPath:(NSIndexPath *)gIndex dataSetToParse:(NSString *)string
{
//Set dataSetToParse so the parsing delegates if statment works correctly
dataSetToParse = string;
//Calls method that sets the accessory tick
[self setAccessoryIndexPath:gIndex];
//Set array that can be used in this view
[parsedDataArray addObjectsFromArray:gArray];
//Use this method to pass NSData object to startTheParsingProcess method and also to initalize indexPathVariable
[self startSortingTheArray:gArray];
}
When I try to log parsedDataArray after I addObjects to it all I get is
(null) (null) .... etc.
any help would be appreciated.
Update The main issue here is that I have 4 lots of arrays. with 3 views, a main view sub view and then a sub subview. each array has a refrence ID to the next array, I want to parse each array before I display them to check if there are any values in them based off the restriction string. If there are no values then I will either send the user back to the main view or just not allow them to select the cell that has an array with no related values. (I hope you get what I am doing here)
The solution I have come up with for that is to parsed the values in the parent view of where I intend to display them...
if you look at my views
view 1
- view 2
-- view 3
I need a parsing delegate for view 1 and 2, because I need to check the values of view 3 in view 2.. However this is causing me an issue because I am using the same array to avid redundancy to return the value to the main view and create/check the values of the subview.
So I am trying to skip over the parser delegates of view 2 if i am not going to display anything in view 3, by passing my already parsed array into the mutablearray I will pass the data back with inside didselectcell method...
Anyway I hope this makes sense.. its the only way I think I can do this.. if you know better please let me know your strategy.
Upvotes: 1
Views: 2168
Reputation: 21
NSArray *array = [NSArray arrayWithObjects:@"Raja",@"Ram",nil];
NSMutableArray *muArray = [NSMutableArray arrayWithArray:array];
Upvotes: 2
Reputation: 1965
check if garray is containing the data or not, by printing it in nslog
also check if u have intialized parsedDataArray as below or not parsedDataArray=[[NSMutableArray alloc]init]; in Viewdidload delegate
Upvotes: 2
Reputation: 8075
Assuming the parsedDataArray is a mutable array declared somewhere else, this wouldn't make sense:
//Set array that can be used in this view
[parsedDataArray addObjectsFromArray:parsedDataArray];
Unless you mean to double all of the objects in the parsedDataArray. I think what you meant is:
//Set array that can be used in this view
[parsedDataArray addObjectsFromArray:gArray];
But I can't be sure without more context or explanation.
Upvotes: 4