gpt4 book ai didi

ios - performSelectorInBackground 上的 EXC_BAD_ACCESS

转载 作者:行者123 更新时间:2023-11-29 10:52:35 26 4
gpt4 key购买 nike

我想在后台调用这个方法,

-(void)downloadImage_3:(NSString* )Path AtIndex:(int)i

我以这种方式调用,但它崩溃并显示 EXC_BAD_ACCESS

[self performSelectorInBackground:@selector(downloadImage_3:AtIndex:) withObject:[NSArray arrayWithObjects:@"http://www.google.com",i, nil]];

如何在后台调用downloadImage_3:方法?

我哪里做错了?

最佳答案

试试这个

[self performSelectorInBackground:@selector(downloadImage_3:AtIndex:) withObject:[NSArray arrayWithObjects:@"http://www.google.com",i, nil]  afterDelay:15.0];

或者试试这个

NSString* number    =   [NSString stringWithFormat:@"%d",i];
NSArray* arrayValues = [[NSArray alloc] initWithObjects:[[msg_array objectAtIndex:i] valueForKey:@"Merchant_SmallImage"],number, nil];
NSArray* arrayKeys = [[NSArray alloc] initWithObjects:@"Path",@"Index",nil];
NSDictionary* dic = [[NSDictionary alloc] initWithObjects:arrayValues forKeys:arrayKeys];
[self performSelectorInBackground:@selector(downloadImage_3:) withObject:dic];

像这样定义 downloadImage_3 函数:

-(void)downloadImage_3:(NSDictionary *)dic 
{
NSString *path = [dic valueForKey:@"Path"];
int i = [[dic valueForKey:@"Index"] intValue];
//Your code
}

关于ios - performSelectorInBackground 上的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19853892/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com