【发布时间】:2011-07-06 16:49:11
【问题描述】:
我在 NSTread 中获取一个字符串作为参数,现在我必须将此字符串传递给下一个方法,我该怎么做呢?我的代码如下: 调用方法并传递一个对象
[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];
}
【问题讨论】:
标签: iphone objective-c methods nsthread