我在NSTread中获取一个字符串作为参数现在我必须将此字符串传递给next方法,那么我该怎么做呢?我的代码如下: 调用方法并传递对象
[self friendPic:user.userId];
我的NSTread
就是这个
-(void)friendPic:(NSString *)friendID{
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(getFriendPic) object:friendID];
[thread start];
[thread release];
}
-(void)getFriendPic:(NSString *)_friendID{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *str =[NSString stringWithFormat:@"http://www.3softcanada.com/ipictures/Image%@.png",_friendID];
NSLog(@"url is%@", str);
NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:str]];
UIImage *theImage= [[UIImage alloc] initWithData:imageData ];
avatar.image = theImage;
[pool release];
}
答案 0 :(得分:0)
您可能需要将selector:@selector(getFriendPic)
替换为selector:@selector(getFriendPic:)
。你错过了冒号。