ASIHttpRequest问题. “无法识别的选择器发送到实例" [英] ASIHttpRequest problems. "unrecognized selector sent to instance"

查看:91
本文介绍了ASIHttpRequest问题. “无法识别的选择器发送到实例"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am experiencing problems using ASIHttpRequst. This is the error I get:

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
)

这是我的代码(部分代码):

And this is my code (Part of it):

// 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];
}

当将注释加载到我的mapview中时,该过程将以标注气泡的LeftCalloutView的形式加载,因此很多(大约80次). 它旨在从服务器中检索XML Plist,对其进行解析并使用数据...但是它死于rackDone:

The process is loaded as LeftCalloutView in the callout bubble when annotations are loaded in my mapview, so quite a lot (80 times or so). It is meant to retrieve a XML Plist from a server, parse it and use the data... but it dies at the rackDone:

有人有什么主意吗?

关于, 保罗·皮伦(Paul Peelen)

Regards, Paul Peelen

推荐答案

我使用[self retain]找到了解决方案.似乎因为我经常加​​载该对象,所以它自身分配的时间不足以接收rackDone:操作.

I found the solution using [self retain]. It seems that because I load the object so often, it doesn't allocate it self long enough to receive the rackDone: action.

现在可以使用.现在,我只需要弄清楚如何应要求加载它,而不是在加载应用程序时.

It works now. Now I just need to figure out how I can load this on request, not when the app is loaded.

这篇关于ASIHttpRequest问题. “无法识别的选择器发送到实例"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆