NSIncation 对象未分配 iphone sdk
我正在做,
NSString *_type_ = @"report";
NSNumber *_id_ = [NSNumber numberWithInt:report.reportId];
NSDictionary *paramObj = [NSDictionary dictionaryWithObjectsAndKeys:
_id_, @"bla1", _type_, @"bla2",nil];
_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initParsersetId:) object:paramObj];
但是即使在处理完这一行之后,我的 _operation 对象也为零。
这里的选择器实际上是我正在编写的一个函数,如下所示:
-(void)initParsersetId:(NSInteger)_id_ type:(NSString *)_type_
{
NSString *urlStr = [NSString stringWithFormat:@"apimediadetails?id=624&type=report"];
NSString *finalURLstr = [urlStr stringByAppendingString:URL];
NSURL *url = [[NSURL alloc] initWithString:finalURLstr];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//Initialize the delegate.
DetailedViewObject *parser = [[DetailedViewObject alloc] initDetailedViewObject];
//Set delegate
[xmlParser setDelegate:parser];
//Start parsing the XML file.
BOOL success = [xmlParser parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error Error Error!!!");
任何
人都可以指出我哪里出错了。
提前致谢。
I'm doing
NSString *_type_ = @"report";
NSNumber *_id_ = [NSNumber numberWithInt:report.reportId];
NSDictionary *paramObj = [NSDictionary dictionaryWithObjectsAndKeys:
_id_, @"bla1", _type_, @"bla2",nil];
_operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initParsersetId:) object:paramObj];
But my _operation object is nil even after processing this line.
The selector here is actually a function I'm writing which is like:
-(void)initParsersetId:(NSInteger)_id_ type:(NSString *)_type_
{
NSString *urlStr = [NSString stringWithFormat:@"apimediadetails?id=624&type=report"];
NSString *finalURLstr = [urlStr stringByAppendingString:URL];
NSURL *url = [[NSURL alloc] initWithString:finalURLstr];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
//Initialize the delegate.
DetailedViewObject *parser = [[DetailedViewObject alloc] initDetailedViewObject];
//Set delegate
[xmlParser setDelegate:parser];
//Start parsing the XML file.
BOOL success = [xmlParser parse];
if(success)
NSLog(@"No Errors");
else
NSLog(@"Error Error Error!!!");
}
Can anybody please point out wheather where I'm going wrong.
Thanx in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的
@selector
与您的方法签名不匹配,这就是它返回 nil 的原因。此外,您不能使用便捷构造函数来传递多个参数。您必须创建一个NSInitation
并使用initWithInitation:
添加参数。http://theocacao.com/document.page/264
Your
@selector
doesn't match your method signature, which is why it's returning nil. Also, you can't use the convenience constructor to pass multiple parameters. You'll have to create anNSInvocation
and useinitWithInvocation:
to add the parameters.http://theocacao.com/document.page/264
选择器的名称是
initWithParserId:type:
,因此正确的行是The name of your selector is
initWithParserId:type:
, so the correct line is