开发者

How to Pass a parameter to a method from NSTread?

i am getting a string as parameter in an NSTread now i have to pass this string to next method so how can i do it? my code is given below: calling method and passing an object

[self friendPic:user.userId];

my NSTread is this

-(void)friendPic:(NSString *)friendID{
    NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(getFriendPic) object:friendID];
    [thread start];
    [thread release];

}

-(开发者_StackOverflowvoid)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];

}


You probably need to replace selector:@selector(getFriendPic) with selector:@selector(getFriendPic:). You missed a colon.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜