iOS 多线程开发以及网络图片加载
NSDictionary*group=[[NSDictionaryalloc]initWithObjectsAndKeys:indexPath,@"indexpath",cell,@"cell",nil];
[NSThreaddetachNewThreadSelector:@selector(loadLabelTableView:)toTarget:selfwithObject:group];
-(void)loadLabelTableView:(NSDictionary*)group
{
UILabel*label=[[UILabelalloc]initWithFrame:CGRectMake(50,10,200,30)];
NSString*codeCharacter=[[m_listDataobjectAtIndex:[[groupobjectForKey:@"indexpath"]row]]substringWithRange:NSMakeRange(0,2)];
NSString*codeNumber=[[m_listDataobjectAtIndex:[[groupobjectForKey:@"indexpath"]row]]substringWithRange:NSMakeRange(3,6)];
NSString*codeName=[[m_listDataobjectAtIndex:[[groupobjectForKey:@"indexpath"]row]]substringWithRange:NSMakeRange(10,4)];
NSString*stockList=[NSStringstringWithFormat:@"%@%@\t%@",codeCharacter,codeNumber,codeName];
label.text=stockList;
[[groupobjectForKey:@"cell"]addSubview:label];
}
网络图片加载方式:
-(void)loadImageCollectionView:(NSDictionary*)group
{
UIImageView*imageView=[[UIImageViewalloc]initWithFrame:CGRectMake(5,2,70,100)];
NSData*data=[NSDatadataWithContentsOfURL:[NSURLURLWithString:[[[listDataobjectAtIndex:[[groupobjectForKey:@"indexpath"]row]]objectForKey:@"images"]objectForKey:@"small"]]];
UIImage*img=[UIImageimageWithData:data];
imageView.image=img;
[[groupobjectForKey:@"cell"]addSubview:imageView];
}