开发者

How to Pass a parameter to a method from NSTread?

开发者 https://www.devze.com 2023-03-18 21:47 出处:网络
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:

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

精彩评论

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