我在使用 ASIHttpRequst 时遇到问题。这是我得到的错误:
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
)
这是我的代码(部分):
// 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];
}
当在我的地图视图中加载注释时,该过程在标注气泡中加载为 LeftCalloutView,所以很多(80 次左右)。它旨在从服务器检索 XML Plist,对其进行解析并使用数据......但它在 rackDone 中死去:
有人有什么想法吗?
问候,保罗·皮伦