我做NSInvocation的對象沒有得到分配的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!!!");
}
可有人請指出wheather我要去哪裏錯了。
Thanx提前。
我已經通過你提供的鏈接了,但在initWithTarget:選擇:對象:,我不能傳遞參數的一個NSDictionary對象直接?我需要對多達10個不同的nsinvocationobjects和Scott Stevenson的方法(這真是太棒了)做這個過程,我會考慮在我的情況下引入冗餘,並且在更改方法簽名之後不會分配它 – neha 2010-06-11 13:30:06
您可以'在NSDictionary中傳遞參數NSInvocation對象是可變的,所以你可以爲10個不同的方法調用編輯同一個對象。 – kubi 2010-06-11 15:14:44