youtube_user_icons
needs to be a NSMutableArray
so that you can change its contents and the line
youtube_user_icons[loop] = [temp_url description];
needs to be
[youtube_user_icons addObject:[temp_url description]];
Question
I have an iOS app which downloads/parses strings from a JSON file. I need to store these strings in ONE NSArray. But every time I try I get the error:
expected method to write array element not found on object of type 'nsarray *'
All I am doing is assigning these strings to the array in a for loop.... And yet it won't work. It is baffling me why... I have assigned strings and variables to an array in C and C++.... Surely Objective-C supports this as well. What am I doing wrong?
Here is my simple for loop:
for (int loop = 0; loop <= [youtube_channel_id_tags count]; loop++) {
self.getYTIcon = [[YTICONGET alloc] init];
NSString *temp_url = [self.getYTIcon get_user_icon:youtube_channel_id_tags[_carousel.currentItemIndex]];
youtube_user_icons[loop] = [temp_url description];
}
What am I doing wrong??
Thanks, Dan.
Solution
youtube_user_icons
needs to be a NSMutableArray
so that you can change its contents and the line
youtube_user_icons[loop] = [temp_url description];
needs to be
[youtube_user_icons addObject:[temp_url description]];
OTHER TIPS
What is your youtube_user_icons
type? Should be NSMutableArray*
, not nsarray *
!