在调用另一个类的方法时抛出一个'NSException'错误实例后调用终止

时间:2011-11-25 22:57:58

标签: iphone ios exception

我正在调用一个方法我的另一个类,但我不能,我得到这个错误。我搜索它,但我找不到任何解决方法。请帮忙。

代码:

adres = [adres stringByAppendingString:[NSString stringWithFormat:@"%@", textArama.text]];

    BaseHttpPost *m_HttpDownloadSearch = [[[self class] alloc] init];
    [m_HttpDownloadSearch HttpPost:adres data:@""];

错误是:

    2011-11-26 00:46:10.386 Sarki Sözleri[1520:207] -[Sarki_So_zleriViewController HttpPost:data:]: unrecognized selector sent to instance 0x4b6ad30
2011-11-26 00:46:10.388 Sarki Sözleri[1520:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Sarki_So_zleriViewController HttpPost:data:]: unrecognized selector sent to instance 0x4b6ad30'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00e315a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f85313 objc_exception_throw + 44
    2   CoreFoundation                      0x00e330bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00da2966 ___forwarding___ + 966
    4   CoreFoundation                      0x00da2522 _CF_forwarding_prep_0 + 50
    5   Sarki SoÃàzleri                     0x0000250e -[Sarki_So_zleriViewController btnAra_click:] + 382
    6   UIKit                               0x000834fd -[UIApplication sendAction:to:from:forEvent:] + 119
    7   UIKit                               0x00113799 -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x00115c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    9   UIKit                               0x001147d8 -[UIControl touchesEnded:withEvent:] + 458
    10  UIKit                               0x000a7ded -[UIWindow _sendTouchesForEvent:] + 567
    11  UIKit                               0x00088c37 -[UIApplication sendEvent:] + 447
    12  UIKit                               0x0008df2e _UIApplicationHandleEvent + 7576
    13  GraphicsServices                    0x0130a992 PurpleEventCallback + 1550
    14  CoreFoundation                      0x00e12944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    15  CoreFoundation                      0x00d72cf7 __CFRunLoopDoSource1 + 215
    16  CoreFoundation                      0x00d6ff83 __CFRunLoopRun + 979
    17  CoreFoundation                      0x00d6f840 CFRunLoopRunSpecific + 208
    18  CoreFoundation                      0x00d6f761 CFRunLoopRunInMode + 97
    19  GraphicsServices                    0x013091c4 GSEventRunModal + 217
    20  GraphicsServices                    0x01309289 GSEventRun + 115
    21  UIKit                               0x00091c93 UIApplicationMain + 1160
    22  Sarki SoÃàzleri                     0x00001d09 main + 121
    23  Sarki SoÃàzleri                     0x00001c85 start + 53
)
terminate called after throwing an instance of 'NSException'

请帮助我!!

2 个答案:

答案 0 :(得分:1)

您不应该使用[[[self class] alloc] init]。你可能想要[BaseHttpPost alloc] init]

答案 1 :(得分:0)

方法-(void)HttpPost:adres data:属于BaseHttpPost类..那么为什么要分配和初始化当前类的对象并从中调用此方法,Sarki_So_zleriViewController也许是调用此方法的viewcontroller而BaseHttpPost有方法