I have a NSMutableArray which is used inside the ASIHTTPRequest process. After the data loading is done, the NSMutableArray stores the info. When I add the data as
[MyArray addObject];
I dont have any errors. However when I insert the data as
[MyArray insertObject:[UIImage imageWithData:data] atIndex:buttonTag];
I have malloc error or index out of range exception issues. I assume this as a thread safety malfunctioning. Any solution for this?
EDITED: in appdelegate.h
@interface{
NSMutableArray *imageArray;
}
in appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
imageArray = [[NSMutableArray alloc] init];
return YES;
}
In the AsyncImageView.h
@interface{
AppDelegate *delegate
}
AsyncImageView.m
- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection {
delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.imageArray insertObject:[UIImage imageWithData:data] atIndex:buttonTag];
}
buttonTagnumber of entries in the array when you insert each image?