-2

我目前正在为 Mac 版 Imgur 编写一个客户端,该客户端允许用户拖放图像,然后将其上传。我刚刚完成了 UploadToImgur 函数的编码,现在我在以下位置收到 SIGABRT 错误:

int main(int argc, char *argv[])
{
   return NSApplicationMain(argc, (const char **)argv);
}

澄清一下,SIGABRT 错误发生在我单击我编码的上传按钮后,该按钮基本上获取图像,将其转换为 NSData,然后将其发送到 uploadToImgur。可以为这两个适用的功能提供代码。

控制台说:

2013-11-04 16:04:22.641 Popup[11274:303] Uploading image.
2013-11-04 16:04:33.602 Popup[11274:303] Server reached successfully.
2013-11-04 16:04:33.603 Popup[11274:303] URL: (null)
2013-11-04 16:04:33.603 Popup[11274:303] *** Assertion failure in -[NSTextFieldCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1265/AppKit.subproj/NSCell.m:1637
2013-11-04 16:04:33.606 Popup[11274:303] An uncaught exception was raised
2013-11-04 16:04:33.606 Popup[11274:303] Invalid parameter not satisfying: aString != nil
2013-11-04 16:04:33.606 Popup[11274:303] (
    0   CoreFoundation                      0x00007fff92fd441c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8f69fe75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff92fd41f8 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff90ff9c61 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   AppKit                              0x00007fff8ba4f918 -[NSCell _objectValue:forString:errorDescription:] + 159
    5   AppKit                              0x00007fff8ba4f86a -[NSCell _objectValue:forString:] + 20
    6   AppKit                              0x00007fff8ba4f7d8 -[NSCell setStringValue:] + 41
    7   AppKit                              0x00007fff8bacb584 -[NSControl setStringValue:] + 138
    8   Popup                               0x0000000100004983 __39-[PanelController btnUploadWasClicked:]_block_invoke_2 + 131
    9   libdispatch.dylib                   0x00007fff895d71d7 _dispatch_call_block_and_release + 12
    10  libdispatch.dylib                   0x00007fff895d42ad _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x00007fff895dbf03 _dispatch_main_queue_callback_4CF + 333
    12  CoreFoundation                      0x00007fff92f3b839 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    13  CoreFoundation                      0x00007fff92ef6b14 __CFRunLoopRun + 1636
    14  CoreFoundation                      0x00007fff92ef6275 CFRunLoopRunSpecific + 309
    15  HIToolbox                           0x00007fff8e217f0d RunCurrentEventLoopInMode + 226
    16  HIToolbox                           0x00007fff8e217cb7 ReceiveNextEventCommon + 479
    17  HIToolbox                           0x00007fff8e217abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
    18  AppKit                              0x00007fff8ba1028e _DPSNextEvent + 1434
    19  AppKit                              0x00007fff8ba0f8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    20  AppKit                              0x00007fff8ba039cc -[NSApplication run] + 553
    21  AppKit                              0x00007fff8b9ee803 NSApplicationMain + 940
    22  Popup                               0x00000001000018b2 main + 34
    23  Popup                               0x0000000100001884 start + 52
)
2013-11-04 16:04:33.610 Popup[11274:303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: aString != nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff92fd441c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8f69fe75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff92fd41f8 +[NSException raise:format:arguments:] + 104
    3   Foundation                          0x00007fff90ff9c61 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
    4   AppKit                              0x00007fff8ba4f918 -[NSCell _objectValue:forString:errorDescription:] + 159
    5   AppKit                              0x00007fff8ba4f86a -[NSCell _objectValue:forString:] + 20
    6   AppKit                              0x00007fff8ba4f7d8 -[NSCell setStringValue:] + 41
    7   AppKit                              0x00007fff8bacb584 -[NSControl setStringValue:] + 138
    8   Popup                               0x0000000100004983 __39-[PanelController btnUploadWasClicked:]_block_invoke_2 + 131
    9   libdispatch.dylib                   0x00007fff895d71d7 _dispatch_call_block_and_release + 12
    10  libdispatch.dylib                   0x00007fff895d42ad _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x00007fff895dbf03 _dispatch_main_queue_callback_4CF + 333
    12  CoreFoundation                      0x00007fff92f3b839 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    13  CoreFoundation                      0x00007fff92ef6b14 __CFRunLoopRun + 1636
    14  CoreFoundation                      0x00007fff92ef6275 CFRunLoopRunSpecific + 309
    15  HIToolbox                           0x00007fff8e217f0d RunCurrentEventLoopInMode + 226
    16  HIToolbox                           0x00007fff8e217cb7 ReceiveNextEventCommon + 479
    17  HIToolbox                           0x00007fff8e217abc _BlockUntilNextEventMatchingListInModeWithFilter + 65
    18  AppKit                              0x00007fff8ba1028e _DPSNextEvent + 1434
    19  AppKit                              0x00007fff8ba0f8db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    20  AppKit                              0x00007fff8ba039cc -[NSApplication run] + 553
    21  AppKit                              0x00007fff8b9ee803 NSApplicationMain + 940
    22  Popup                               0x00000001000018b2 main + 34
    23  Popup                               0x0000000100001884 start + 52
)
libc++abi.dylib: terminating with uncaught exception of type NSException

有任何想法吗?可以提供更多信息。

4

2 回答 2

0

When a window is displayed, the associated text fields can not be set to nil. If you set the NSTextField string value to nil, you will see this problem. So to resolve this, make sure you do not set them to nil.

Declaration:

IBOutlet NSTextField *username;

Implementation:

- (id)initWithWindow:(NSWindow *)window
{
    self = [super initWithWindow:window];
    if (self) {
        [username setStringValue:@"User"];
    }
    return self;
}
于 2015-01-08T04:48:15.227 回答
0

问题似乎是您将错误的论点传递给该方法。只需放置断点并检查您传递了错误参数的某些行。

于 2013-11-05T03:05:17.600 回答