Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone ASITPPrequest问题&引用;已将无法识别的选择器发送到实例";_Iphone_Asihttprequest_Iphone Sdk 3.2_Mkannotation - Fatal编程技术网

Iphone ASITPPrequest问题&引用;已将无法识别的选择器发送到实例";

Iphone ASITPPrequest问题&引用;已将无法识别的选择器发送到实例";,iphone,asihttprequest,iphone-sdk-3.2,mkannotation,Iphone,Asihttprequest,Iphone Sdk 3.2,Mkannotation,我在使用AsitpRequest时遇到问题。这是我得到的错误: 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890 2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** Terminating app due to uncaught exception '

我在使用AsitpRequest时遇到问题。这是我得到的错误:

2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890
2010-04-11 20:47:08.176 citybikesPlus[5885:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[CALayer rackDone:]: unrecognized selector sent to instance 0x464a890'
2010-04-11 20:47:08.176 citybikesPlus[5885:207] Stack: (
    33936475,
    2546353417,
    34318395,
    33887862,
    33740482,
    126399,
    445238,
    33720545,
    33717320,
    40085013,
    40085210,
    3108783,
    11168,
    11022
)
这是我的代码(部分代码):

当注释加载到my mapview中时,该过程将作为调用编号中的LeftCallout视图加载,所以加载次数相当多(大约80次)。 它意味着从服务器检索XML Plist,解析它并使用数据。。。但它在拉克多死了:

有人有什么想法吗

问候,,
Paul Peelen

好吧,问题似乎是您的
networkQueue
对象(无论是什么NSOperationsQueue子类?)正在将
rackDone:
消息发送到viewController的视图,而不是viewController本身。Calayer是视图的属性,而不是ViewController,因此错误必须来自视图

检查
网络队列
的代码


您似乎也没有为
networkQueue
使用
self
表示法,如果它是类的属性,它可能会在没有警告的情况下死亡,因为它没有正确保留

我使用
[self-retain]
找到了解决方案。似乎因为我经常加载对象,所以它自身分配的时间不够长,无法接收rackDone:action

现在可以了。现在我只需要弄清楚如何根据请求加载,而不是在加载应用程序时加载

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{

 [image setImage:[UIImage imageNamed:@"bullet_rack.png"]];

 BikeAnnotation *bike = [[annotationView annotation] retain];

 bike._sub = @"";

    [super viewDidLoad];

 NSString *newUrl = [[NSString alloc] initWithFormat:rackUrl, bike._id];
 NSString *fetchUrl = [newUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

 [networkQueue cancelAllOperations];
 [networkQueue setRequestDidFinishSelector:@selector(rackDone:)];
 [networkQueue setRequestDidFailSelector:@selector(processFailed:)];
 [networkQueue setDelegate:self];

 ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:fetchUrl]] retain];
 [request setDefaultResponseEncoding:NSUTF8StringEncoding];
 [networkQueue addOperation:request];

 [networkQueue go];
}

- (void)rackDone:(ASIHTTPRequest *)request
{
 NSString *resultSearch = [request responseString];

 NSData *data = [resultSearch dataUsingEncoding:NSUTF8StringEncoding];

 NSString *errorDesc = nil;
 NSPropertyListFormat format;
 NSDictionary * dict = (NSDictionary*)[NSPropertyListSerialization
            propertyListFromData:data
            mutabilityOption:NSPropertyListMutableContainersAndLeaves
            format:&format
            errorDescription:&errorDesc];

 rackXmlResult* fileResult = [[[rackXmlResult alloc] initWithDictionary:dict] autorelease];
 rackXmlSet *rackSet = [fileResult getRackResult];

 NSString *subString = [[NSString alloc] initWithFormat:@"Cyklar tillgängligt: %@ -- Lediga platser: %@", rackSet._ready_bikes, rackSet._empty_locks];

 [activity setHidden:YES];
 [image setHidden:NO];

 BikeAnnotation *bike = [annotationView annotation];

 bike._sub = subString;
}

- (void) processFailed:(ASIHTTPRequest *)request
{
 UIAlertView *errorView;

 NSError *error = [request error];
 NSString *errorString = [error localizedDescription];

 errorView = [[UIAlertView alloc]
     initWithTitle: NSLocalizedString(@"Network error", @"Network error")
     message: errorString
     delegate: self
     cancelButtonTitle: NSLocalizedString(@"Close", @"Network error") otherButtonTitles: nil];

 [errorView show];
 [errorView autorelease];
}